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!
在D365O中循环显示窗体中的所有记录 / Loop through all the records on a form in D365O
与本文相关的文章
- 首席运营官的挑战 / COO challenges
- D365O – 现有贸易协议的价格调整 / D365O – Price correction for existing Trade Agreements
- Code for display method to find/stimulate the purchase price for an item and vendor
- Data Validation Checklist in Dynamics 365 for Operations
- Dynamics 365 for Operations – Where to start!
- Dynamics 365 for Finance and Operation, Enterprise edition (on-premises) system requirements