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;
if(localInventItemPurchSetup)
{
while(localInventItemPurchSetup)
{
info(localInventItemPurchSetup.FieldName);
localInventItemPurchSetup = InventItemPurchSetup_ds.getNext() as InventItemPurchSetup;
}
}
}
Cheers!
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;
if(localInventItemPurchSetup)
{
while(localInventItemPurchSetup)
{
info(localInventItemPurchSetup.FieldName);
localInventItemPurchSetup = InventItemPurchSetup_ds.getNext() as InventItemPurchSetup;
}
}
}
Cheers!
No comments:
Post a Comment