Skip to main content

Notifications

Announcements

No record found.

How to run Runnable class via URL in D365. #ax #d365 #dynamics

 Hello everyone, The Runnable class can be used in a variety of ways. One method is to use Visual Studio to set up your project as the startup object and your runnable class as the startup object, then execute it from there. An alternative method is to add it to any form, attach it to a menu item, and then use the menu item to execute it. You may also run it directly from your browser.

I needed to add a new field to the VendTable, and it needed to have the same value as another VendTable column. The idea is for me to write some code in insert() and update() method to update the new field and to run a Runnable class to copy the old data for the first time.
 
//Runnable class
internal final class test
{
    /// <summary>
    /// Class entry point. The system will call this method when a designated menu
    /// is selected or when execution starts and this class is set as the startup class.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        VendTable vendTable;
        ttsbegin;
        //It'll run for all companies 
        while select forupdate crosscompany vendTable
        {
            changecompany(vendTable.DataAreaId)
            {
                vendTable.NewTax1099RegNum = vendTable.Tax1099RegNum;
                vendTable.update();
            }
        }
        ttscommit;
        /*
        //For single company
         while select forupdate vendTable
        {
                vendTable.NewTax1099RegNum = vendTable.Tax1099RegNum;
                vendTable.update();
        }
        */
    }
 
}
 
Run any Runnable class directly from browser is pretty simple. 
https://URL> /?cmp=USMF&mi=SysClassRunner&cls=test
Parameters:
cmp = Your company name e.g USMF
cls = Your Runnable class name e.g. test
 
e.g.: https://lcs-dev72ad62devaos.cloudax.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=test

Comments

*This post is locked for comments