Thursday, December 27, 2018

Trigger logic App from D365 Part 2







In this part we will see how to trigger logic app form D365FO (Dynamics 365 For operations)


For logic App details visit Part 1 

Create a class name :LogicAppHelper
with method : callPostWebAPI


class LogicAppHelper
{
    #define.ApplicationJson('application/json')

    public boolean callPostWebAPI(URL _serviceOperation, Comments _postData, str _header ='')
    {
        RetailWebRequest request;
        RetailWebResponse response;
       
        boolean ret;
        ListEnumerator  listEnmr;
        List dataList;
        RetailCommonWebAPI webApi = RetailCommonWebAPI::construct();
   
        try
        {
            response = webApi.makePostRequest(_serviceOperation, _postData, _header #ApplicationJson);

        }
        catch
        {
            ret = false;
        }
   
        return ret;
    }
}



Now we will create runable class (job)

class LogicAppConnectionJob
{        
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {    
        LogicAppHelper  appHelper = new LogicAppHelper();
        container       conValues;
        AccountNum custAccount;
        str             callingparam ;
        ;
        
        custAccount = 'US-001';

        callingparam  = "{'CustomerAccount':'" + custAccount +" '}";

       //appHelper.callPostWebAPI(URL ,Comments,_header
       // URL : URL generated while creating logic for details see part 1
       // Comments: passing customer account to logic app as JSON Schema for details see part 1

        appHelper.callPostWebAPI('https://URL-Generated-By-Logic-App-Response-Receiver' ,callingparam);
    }

}

hopefully this will help you all...

No comments:

Post a Comment

D365FO. Dynamics 365 fiance and operation. Get and update contract of batch job on Controller run method. ax 2012

set Batch id in contract if batch isInBatch check is true in run method we will update the contract and set the batch id. class BrFunc...