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...

Monday, December 24, 2018

Logic App For Dynamics 365 for operation (D365FO).Azure logic App (part 1)









Summary :
In this part we are going to create Logic App for Dynamics 365 For Operations.in this we will see how we will send email using logic app.
As we know right now there are no triggers for D365 FO, so we will achieve this using http response receive.
In this part we will discuss


a)      Login azure portal.
b)      Create Resource for logic app.
c)      Create basic logic app 
d)      And trigger logic using post man 

Part 2

  
Step 1:
Sign in azure portal



Step 2:
After log in, go to Create a resource à Web à Logic App



Step 3:
a. Enter logic app name e.g DemoLogicApp.
b. Select Subscription.
c. Check Create new in resource group.
d. Enter resource group name like DemoResourceGroup
e. Select location
f. Click on create.

Step 4:
Click All services
filter by Logic App



Step 5:

Click DemoLogicApp
It will open logic App Designer
Select Blank Logic App


It will look like 




 Step 6:
First we will add trigger to logic app(trigger is the point which define when to execute logic app)
 a)      Search for logic app trigger (When a Http Request is Recevied)

 b) Select When a Http Request is received 
  




 c) Now add Json Schema: 
Step 7:
a)  Now we will add action. Click next step


    b) Search for send email action
    c) Select Office 365 Outlook

   d)  Select send Email


 e)  Now we will sign in to office 365 Outlook.

  f)    Fill details
a.       Add to account
b.      Subject
c.       Body (you can add customer account which was define in jSon Schema.


Step 8:
Click on save
It will generate Https url
  Step 9:
        a)      Go to post man
        b)      Select post
        c)       Enter url
d      d)  Go to header tab add key and value 
    e) Go to body and define body (we defined json Schema in logic app)         


    f)  Click on send
    g)  Go to logic app àOverview à click refresh
We can see the status is succeeded which mean logic app got triggered and send email successfully 




in next part we will discuss how to connect D365 with logic apps 


Part 2 in this part we will discuss how to trigger Logic App From D365


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...