How to: Pass multiple data source records to Class
Good day everyone! Today I will post about how to pass value from form to class, to be more specific I will show how to pass only the selected values to your class through args.
Passing values from form to class is very common, specially if we want pass a specifc information to Dialog, I tried to be as detailed as possible using the Customer List Page as example.
1. Create the class which will receive Args from our menu item button.
2. Create the method main and use the following code:
public static void main(Args _args)
{
CustTableListPageDialog dialogClass;
CustTable custTable;
FormDataSource custTable_ds;
;
//Check if the Args.Record() has the same TableID as the Table Buffer(custTable).
if (_args.record().TableId == tableNum(custTable))
{
//Assign the args records to table buffer and then pass it to salesLine_ds(FormDataSource)
custTable = _args.record();
custTable_ds = custTable.dataSource();
//Call Method which will be used to create the Dialog
dialogClass = new CustTableListPageDialog(custTable_ds);
}
}
3. Create the method which will be used to create the Dialog.
public void new(FormDataSource custTable_ds)
{
Dialog dialog;
CustTable row;
;
//Create a Dialog with title
dialog = new Dialog('Title' );
//Create a "Label" do Dialog
dialog.addText( 'Do you wish to proceed?');
//The code will only be executed if the user click on Yes
if (dialog.run())
{
//This will check if there is any record marked
if (custTable_ds.anyMarked())
{
//Obtains the first query result and then assign it to table buffer
row = custTable_ds.getFirst( 1, false );
//True if purchLineView contains RecId
while (row)
{
//Shows all RecIds from selected grid rows
info( strFmt('%1' , row.RecId));
//Gets next record
row = custTable_ds.getNext();
}
}
}
}
4. Create the Menu Item Display. For example, I have set the following properties:
| Label | Update Backorder |
| ObjectType | Class |
| Object | PurchLineBackOrderDialog |
5. Now I will use the form CustTableListPage as an example, on form Design locate the ActionPaneTab, create a Button Group and set the propertie Caption. Then drag and drop the MenuItem to Button Group. It should look like this.
7. A simple button would be to boring, so let’s make it more “user friendly”.
| NormalImage |
<Insert Image Location here>
|
| ImageLocation | File |
| MultiSelect | Yes |
| Big | Yes |
| MenuItemName | CustTableListPageDialog |
8. We are done! Check results.
Selecting multiple records and then clicking on our newly created button.
As you can see below our class got only the selected records.
This was originally posted here.

Like
Report




*This post is locked for comments