22 Mar 2013

How to traverse multiple selected lines in a grid control by using X++ code

Do this when multiple rows of the information in the grid control contain the information which is required to perform the required request.

For example, you can use the following code in the click event of the button if you want to traverse two selected lines when the second row and the fourth row are highlighted in a grid control.

void clicked()
{
CustTable ct;
;
//ct is set to the forms data source and using a cursor goes through each record selected in the grid.
for (ct = DataSource1_ds.getFirst(true) ? DataSource1_ds.getFirst(true): DataSource1_ds.cursor(); ct;ct=DataSource1_ds.getNext())
{
print ct.AccountNum," ",ct.Name;
}
super();
}

No comments:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...