web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

Order a grid datasource based on a field does not work without refreshing manually

(0) ShareShare
ReportReport
Posted on by 152

Hello all,

I have a grid on a form, and when i add a new record on a grid i want the grid to be order based on a field( "A lung" in my example)

If i add this row, this field (4<6) , i need this row to go the second record not the third. I added this code on onInitialized() of datasource :

FormRun formRun= sender.formRun();
Object bfpProdRollQCMappingDetailTmp_ds = formRun.dataSource(formDataSourceStr(bfpProdRollQc, bfpProdRollQCMappingDetailTmp)) as FormDataSource;


bfpProdRollQCMappingDetailTmp_ds.queryBuildDataSource().addSortField(fieldNum(bfpProdRollQCMappingDetailTmp, PositionYTo));

8272.record.PNG

The rows are ordered only if i do refresh manually, otherwise no. I tried to add refresh(), reread() , research() of the datasource but still does not work.

Thank you in advance.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Paula,

    Where did you try calling the refresh(), reread() method?

  • PaulaRystemi6 Profile Picture
    152 on at

    On OnInitialized() of datasource event...Where should i add?

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Paula,

    If you are trying to rearrange the rows after adding a record, please try the write method or the onWritten datasource event. Please try the research method in this case and check if that works.

  • PaulaRystemi6 Profile Picture
    152 on at

    Yes it works so well, thank you very much

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Please do make sure that this doesn't cause any performance issues since this will refresh every time a record is added or edited.

  • PaulaRystemi6 Profile Picture
    152 on at

    It looks like it has a problem on research(), because it takes the old values of the grid ordered, not the new ones that i added

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Paula,

    It should work on the new values as well. Could you please share your code?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 284 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 178 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 116 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans