D365/AX7: Method to call when record is marked – markChanged() FormDataSource


The requirement was to display information of selected records of form Grid on a string control.The information on custom string control should change during the marking of records in real time.

Sample Code:

Copy the method in form datasource.

  1. public void markChanged()
  2.         {
  3.             AcxBrandMaster  acxBrandMaster1;
  4.             str brandStr;
  5.             MultiSelectionHelper    multiSelectionHelper =  MultiSelectionHelper::construct();
  6.             multiSelectionHelper.parmDatasource(AcxBrandMaster_DS);
  7.             acxBrandMaster1 = multiSelectionHelper.getFirst();
  8.             FormStringControl1.text(“”);
  9.             while (acxBrandMaster1.RecId)
  10.             {
  11.                 brandStr = brandStr +  acxBrandMaster1.Brand;
  12.                 acxBrandMaster1 = multiSelectionHelper.getNext();
  13.             }
  14.             FormStringControl1.text(brandStr) ;
  15.             super();
  16.         }

D365/AX7: Using SysReferenceTableLookup For Reference Group In Form (Missing LookUpReference Event)


Vendor Address Lookup in purchase order creation form (PurchCreateOrder).

Sample Code

For simple form control, we can use SysTableLookUp class & write code in onlookup event of form control.The sample code is mentioned in below line:

D365/AX7: Extend Form Control OnLookup Event On Standard Form

But for reference group control in form, SysTableLookup doesnot work.There is  one different class called  SysReferenceTableLookup For Reference Group In Form.Also in D365 there is no event related LookUpReference method.So i am using OnLookup event.

class AcxPurchCreateOrderFormEvents
/// <summary>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchCreateOrder, PurchTable_AcxDeliveryPostalAddressVend), FormControlEventType::Lookup)]
public static void PurchTable_AcxDeliveryPostalAddressVend_OnLookup(FormControl sender, FormControlEventArgs e)
VendTable vendTable;
Common common;
PurchTable purchTable = sender.formRun().dataSource(formDataSourceStr(PurchCreateOrder,PurchTable )).cursor();
VendTable = VendTable::find(purchTable.OrderAccount);

SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup ::newParameters(tableNum(LogisticsPostalAddress),sender);
Query q = new Query();
QueryBuildDataSource qbds;
qbds = q.addDataSource(tableNum(LogisticsPostalAddress));
sysTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Location));
sysTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Address));
FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;