In Microsoft Dynamics 365 for Finance and Operations, there may be situations where you need to pass data between different forms. This can be accomplished by using the Args
class, which facilitates parameter passing between forms.
Let’s walk through an example where we’ll create two forms—FormA and FormB—and pass a parameter from FormA to FormB.
Steps to Implement Parameter Passing:
1. Create Two Forms
-
FormA: This is where you will input the data you want to pass.
-
FormB: This is where you will receive the data.
2. Override the clicked()
Method in FormA
In FormA, you will override the clicked()
method of the button (or any action you want to trigger) to pass the parameter to FormB. Here’s how:
-
In the code above, the
parm()
method of theArgs
class is used to pass the value of a string (such as a leave request ID) from FormA. -
We also pass an entire record (e.g., a
TableName
) using therecord()
method. -
Finally, we initialize and run FormB using the arguments.
3. Override the init()
Method in FormB
In FormB, you will need to override the init()
method to receive and process the parameters passed from FormA. Here's an example of how to retrieve the string and record:
-
In the
init()
method of FormB, we use theelement.args()
method to get the arguments passed from FormA. -
The
parm()
method retrieves the string value (in this case, the leave request ID), and therecord()
method retrieves the entire record (e.g., a specific table record). -
The retrieved values can then be used within FormB, such as displaying the leave request ID or working with the passed record data.
Conclusion
This simple example demonstrates how to pass parameters from one form to another in Dynamics 365 FO using the Args
class. You can pass both simple data like strings and more complex data like entire records, making it easy to transfer information between forms in your applications.
0 Comments