Thursday, March 9, 2023

D365 Retain record position on grid refresh

Microsoft Dynamics 365 Finance
When refreshing the datasource of a grid, a common requirement is to retain the position of the selected record.
The datasource function refresh(true) was supposed to handle this, but does not always work. Also getPosition() and setPosition() will not provide this functionality.

One way to solve it is to use findRecord(Common _record). For this to work you will need to fetch the record from the database, as simply using the cursor() record will not suffice.

  MyTable myTableCursor = MyTable_ds.cursor();
  MyTable myTableLocal = MyTable::findRecId(myTableCursor.RecId);
  MyTable_ds.executeQuery();
  if(myTableLocal)
  {
  	MyTable_ds.findRecord(myTableLocal);
  }

Monday, March 6, 2023

Build and sync menu items greyed out

Microsoft Dynamics 365 Finance
Just encountered a situation where the D365 "Build models" and "Synchronize database" menu elements in VS were disabled.
Solution turned out to be very simple:
Close Visual Studio and restart IIS