Monday, March 5, 2018

Loop through all the records on a form in D365O

Below sample code can be used to loop through all the records on a form in D365O

Assuming that we want to infolog a field value for all the records on the screen on the click of a button.

Step 1: Create a new class
Step 2: Add the below code which should be called on the click of the button and info the required field details

static class Test_LoopThruRecords_Extension
    /// <summary>
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(InventItemOrderSetup, Test_BtnLoopThruRecords), FormControlEventType::Clicked)]
    public static void Test_BtnLoopThruRecords_OnClicked(FormControl sender, FormControlEventArgs e)
        FormDataSource              InventItemPurchSetup_ds  = sender.formRun().dataSource("InventItemPurchSetup"); //DataSource form InventItemPurchSetup

        InventItemPurchSetup        localInventItemPurchSetup = InventItemPurchSetup_ds.getFirst() as InventItemPurchSetup;

                localInventItemPurchSetup = InventItemPurchSetup_ds.getNext() as InventItemPurchSetup;


No comments:

Post a Comment