- (619) 483-4180
- info@avantiico.com
Product Selection Tools
Evaluation Guides
Readiness Overview
Identifying Stakeholders
Managing Expectations
Prepare to be Prepared
Upgrade Services
Project Management
Roadmap Services
Data Migration
Data & Analytics
Avantiico Industry Solutions
Explore by Business Need
Avantiico Industry Solutions
Microsoft Platforms
Licensing & Pricing Options
Our Partners
Careers
Avantiico Academy Program
About Avantiico
The Microsoft Dynamics AX/D365 Support Team at Avantiico is focused on solving our client’s problems, from daily issues to large and more complex problems. Cindy is a true AX veteran and hold 20 years dedicated Senior Consulting experiences for Microsoft Dynamics AX Software.
You have a class that extends RunBase using the standard dialog for entering parameters. On that standard dialog form you add a button calling a menu item. This works well for starting reports or triggering some static behavior, but what if you need to pass a parameter to the target of that button? Several other blogs have covered adding a button to a RunBase dialog, but in this post we’ll dig a bit deeper to show how a parameter can be passed and captured on the target object using accessor methods.
From a high level, this problem seems like it should be easy enough. However, there are a couple of tricks involved which we’re hoping to expose. Let’s start with the following example: We’ve developed a class for validating file permissions and programmed it such that it can run stand-alone using its own dialog. We’ve also made it capable of running silently if given some requisite parameters. Further, when running silently we can gather the needed parameters from the calling object if we can determine the calling class. First we’ll show how to add a button to a RunBase dialog, then we’ll show how to interrogate the parameter from the caller in the target class using an accessor method. Note that the code in this solution was taken from an AX 2009 implementation, the methodology may differ in Dynamics AX 2012.
The key to this solution is that instead of thinking of the caller “pushing” the parameter to the target, we need to implement a method of “pulling” the parameter from the caller.
In our RunBase class (I’m going to refer to this as the caller or calling class in this solution; it’s also named OurReport in the code) we have a pretty standard implementation of the “dialog” and “getFromDialog” methods. In the following snippet, you’ll see the addition of the menu item button highlighted.
Likewise, “GetFromDialog” is pretty straight forward, we’re just setting some local variables from the fields on the dialog.
Now, we need an accessor method for our target class to call and interrogate the caller for a file path. We implemented this as a “parm” method to follow AX naming convention. A couple of things to notice with this method:
Now we can take a look at the main method on the target class.
The “pull” accessor method parmFilePath is nothing new, but it’s being used here in a non-standard way. Typically parm methods are used on the target class, not on the source, but we need a way to pull the file path value on the dialog in the source class into the validation method on the target class.
Second point of interest is that this main method contains two distinct code paths – one in which no arguments are issued, and one with a caller. First is the path using the caller method on args. In order to ensure that this code path is only applied when the target class is called from our report, we needed to test whether the caller’s RunBase class is OurReport.
In AX 2012 we would simply use the “Is” and “As” operators to test the caller and downcast it appropriately (as explained on MSDN here: http://msdn.microsoft.com/en-us/library/gg843452.aspx). In AX 2009 and AX 4 the code looks like the following:
This code allows us to compare the argument’s caller instance with OurReport, and then assign a local object of OurReport to the caller instance. With a local copy of OurReport, we can use the parmFilePath accessor method to retrieve the file path from the caller’s dialog.
We hope this methodology and code sample will be useful for our fellow developers. Check back soon for more!
Multi-company reporting is crucial for organizations managing several legal entities. This blog delves into how Avantiico’s Advanced Multi-Company Solution (AMCS) enhances Dynamics
Revolutionize your 3PL warehouse with Microsoft Warehouse Only Mode and the 3PL Automation Cloud. Streamline operations, integrate multiple ERPs, and boost efficiency.
Introduction Managing the total cost of imported goods is essential in today’s global market. The Microsoft Dynamics 365 Supply Chain Management Landed
Avantiico® is a registered trademark of Avantiico, Inc.
600 B Street, Suite 300, San Diego, CA 92101 | (619) 483-4180 | info@avantiico.com
Discover how Avantiico helps you improve business processes, provide customers with a seamless experience and transform the way you do business.
Discover how Avantiico helps you improve business processes, provide customers with a seamless experience and transform the way you do business.