Runnable Class URL Parameters in Dynamics 365 Finance and Supply Chain Management
Recently, I've had to help clients using Dynamics 365 Finance and Supply Chain Management who need to fix some data.
However, clients need to review the data before proceeding with any updates or deletes. There are several options to update data, including:
- Runnable class
- Update script
After assessing the situation and requirements, I decided to go with a runnable class, although a primary issue with this method is that runnable classes aren't very interactive. While a runnable class would include a message box as a means of controlling flow, the interruption felt suboptimal. For this particular situation, I already had to enter the URL for the SysClassRunner, so it seemed natural to add another parameter to the URL to resolve the issue.
Let's call this param1 to keep things simple and say it accepts a string. The URL should now look something like this:
- <envLink>/?cmp=dat&mi=SysClassRunner&cls=MyRunnableClass¶m1=false. (Note that in the URL and in the code, "param1" is not case sensitive.)
Now, we need to establish how to access this new parameter. In your code base, you can find and use a .NET class "URLUtility." For this blog, we will only touch on one aspect of the class, but it's simple to use in this case in two steps:
1 - Create your own runnable class
Public class MyRunnableClass { public static void main(Args _args) { } }
2 - Add code to your main method
URLUtility utility = new URLUtility(); str parameter = utility.getQueryParamValue(‘param1’); if(parameter == ‘’) // if you want to make this required { throw error(‘error text’); } // place code here to run all the time MyRunnableClass::queryCode(); if(parameter == ‘true’) { // place code here to run only when true MyRunnableClass::updateCode(); }
And that's it! You can now control program flow from a URL parameter for your runnable class. You can use this in conjunction with extra logging or you can show information in the infolog for a user. I encourage you to check out the URLUtility and System.Uri to see more of what you can access there.
Get in touch with Stoneridge Today to Learn More!
Talk to our team of experts today to learn more about how you can address data management
Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.
Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.