Loading...

D365 X++ Passing parameters in Microsoft Dynamics

D365 X++ Passing parameters in Microsoft Dynamics

 Args is your companion in the world of X++ especially when passing parameters in Microsoft Dynamics AX. Args is an abbreviation for arguments. It allows you to pass information from one object to another newly created object. I utilize it frequently to pass the objects, records, strings, etc that I need to have in scope while accessing the object from another object. It’s very easy to utilize the Args class to get the desired result you’re looking for.

The following example demonstrates how to create an instance of the Args class:

Declaration of Args

Args  args = new Args();
CustTable  custTable;

Setting record is Args

select custTable where custTable.AccountNum == ‘XXXX’

if(custTable)
{
args.record(custTable);
}

 

Some important methods of Args class

Caller

Get or sets the instance of the object that created this instance of the Args class.

Name

Gets and sets the name of the application object to call.

Parm

Gets or sets a string that specifies miscellaneous information for the called object.

parmEnum

Gets or sets the enumeration value of the enumeration type that is specified in the parmEnumType method.

parmEnmType

Gets or sets the ID value of any enumeration type.

ParmObject

Gets or sets an instance of any object to pass, to the called object.

Record

Gets and sets the record from the table on which the caller object is working.

 

Sample Code  For Setting Value in Args

Create an instance of the Args and custom class.

 Args  args;
CustTable  custTable;
//custom class object to pass
Student student= new Student();
args = new args();

Set the parameter which you want to pass. If you just want to pass a simple string you can do it like this

 args.parm("Hello World");

If you want to pass an enum value you can do so via following code.

args.parmEnum( NoYesEnumValue.selection() );
args.parmEnumType( EnumNum( NoYes ) );

If you want to pass table buffer  in parameter

args.record( EmplTable );

If we want pass a more complex set of parameters, you can develop your own class just for passing those parameters.

student.parmName(‘William’ );
student.parmRollNum(‘st-123‘);
args.parmObject(student);

If you to pass records from a table, use following code.

select custTable where custTable.AccountNum == ‘XXXX’

if(custTable)
{
args.record(custTable);
}

 

Sample Code  For Getting  Value From Args

Create an instance of the Args class and your custom class.

Args   args;
CustTable  custTable;
//custom class object to pass
Student student= new Student();
args = new args();

Check that the passed arguments are not null

if( element.args() )
{
.....
}

Get string value

strValue.text( element.args().parm() );

Check parmEnum is not null and then get enum parameter

if( element.args().parmEnumType() == EnumNum( NoYes ) )
{
NoYesEnumValue.selection( element.args().parmEnum() );
}

Check parmEnum is not null and then get object

if( element.args().parmObject() )
{
student = element.args().parmObject();
}

Check that the table buffer is not null and then get record.

if( element.args().record() && element.args().record().TableId == TableNum( CustTable ) )
{
custTable=  element.args().record();
}

Published on:

Learn more
Sherif Fayed
Sherif Fayed

Share post:

Related posts

D365 Sending Email with Customer Account Statement SSRS report as attachment using X++

D365 Sending Email with Customer Account Statement SSRS report as attachment using X++ custTable _custTable;        &...

2 days ago

clicking link on info message X++ to Open form

 Message::AddAction() method can be used to embed an action within a message sent to the message bar. This method supports adding a singl...

3 days ago

Implement Periodic Data Export from D365FO to SFTP

This blog post describes how to implement various scenarios for periodic data export from D365FO to a file and uploading it to SFTP server.

14 days ago

[New Feature] Financial Consolidation Template in Microsoft Dynamics 365 Finance and Operations

🚀 New Feature Online Consolidation Template! 🚀 This feature streamlines the financial consolidation process and enhances the user experience...

27 days ago

[New Feature] Bank Account Lifecycle Management in Microsoft Dynamics 365 Finance and Operations

🚀 New Feature: Workflow approvals for Bank master! 🚀 Microsoft has recently added a new preview feature in Microsoft Dynamics 365 Finance an...

27 days ago

Business Performance Analytics in Microsoft Dynamics 365 Finance and Operations: Part-2

📢 Now Time to Business Performance Analytics in Microsoft Dynamics 365! Let’s dive into the various reports available in Business Perfo...

27 days ago

Business Performance Analytics in Microsoft Dynamics 365 Finance and Operations: Part-1

📢 Now Time to Business Performance Analytics in Microsoft Dynamics 365! While we focus on new developments around Copilot and AI, let’s...

27 days ago

Dual Currency Valuation/Reporting using Global Inventory Accounting in Microsoft Dynamics 365 Finance and Operations: Part-12

📢 Part-3: Now Time to Explore Global Inventory Accounting in Microsoft Dynamics 365! 🌍 Welcome to the next part of Global inventory accounti...

27 days ago

Configure Reporting for Global Inventory Accounting in Microsoft Dynamics 365 Finance and Operations: Part-11

📢 Part-2: Now Time to Explore Global Inventory Accounting in Microsoft Dynamics 365! 🌍 In the next part of our Global Inventory Accounting s...

27 days ago

Global Inventory Accounting in Microsoft Dynamics 365 Finance and Operations: Part-10

📢 Now Time to Explore Global Inventory Accounting in Microsoft Dynamics 365! 🌍 I’m excited to dive into one of the most powerful featu...

27 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy