Passing Records among Forms on Specific Action using Args

Assume a scenario where we have two forms (1)Sales Table (2)Customer Table and we have to pass records from one form to other form on a specific action (e.g. clicked ...)  first declare Args object as follow:

Args args;
args = new args();

Then specify the record to be passed (assume that Sales Table is the data Source of our form):

args.record(salesTable.SalesId);
now our record is set in args.record, to pass it to another form call that form as follow:
 
 new MenuFunction(menuitemDisplayStr(CustTable), MenuItemType::Display).run(args);
This line of code will rum the customers form and now we can use that record .
In addition to check whether our record is valid i.e.it's not Null or its data-source is Sales Table or not....


if(element.args().record() && element.args().dataset() == tableNum(SalesTable))
{
     custTableLocal = element.args().record();
}

The above line of code verify the record and its data set i.e. Sales Table and allocate that record to a variable.
Now we are all done and can use the record on customers Form :-)

Comments

Popular posts from this blog

D365: SSRS Report Development/ Customization

D365: X++ code to add custom lookup on worker to show specific workers team workers only

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"