The Azure DocumentDB Blog

All about DocumentDB and Logic Apps

Month: April 2016 (page 1 of 2)

Working with Salesforce Api App

The Salesforce API  App (Connector} can be used to trigger an Logic App.

It will fire the trigger on a New record or an Update to a record.

In actually it is a polling process.  It defaults to one hour for the Basic Service Plan.,

In order to debug and test you will need to upgrade the Standard Service Plan.  This will allow you to set the trigger to one minute.

I am working on a project where I needed to synchronize records between CRMOL and Salesforce.

I needed to sync the parent record and several custom child records.  I needed to create two Logic Apps for each record type, one for Insert and the other Update.

I ran into some issues with the way the Salesforce App works.

You would assume that you would get a trigger for New Records and another for Update Records. But that’s not what was happening.

This is how it works

  • Create a new Parent record fires the Insert and update a Parent record fires the Update.
  • Create the first Child Record of one type,  fires both Insert Child and Update Parent
  • Create the more Child Records of one type, fires both Update Child and Update Parent
  • Update the  Parent record,  fires Update Parent.
  • Update a child record, fires both Update Parent and Update child

The issue was that I need to Insert and Update the same type of records in CRMOL.

In order to do an update,  I needed the Parent Record Id from CRMOL.  This works fine for updates. But doesn’t work for new records that are being inserted as a Update.

To solve the problem I need to insert a Get action right after the trigger fired.  I need to query the Parent records for the Id that I needed to do the update with. Then I need to create an expression that wouldn’t return a run-time error if the field did not exist.  The following code sample shows the expression.

  "expression": "@or(equals(not(empty(body('Get_PrescriberAccountId')?['CRM_HUB_ID__c']))), equals(not(empty(triggerBody()?['CRM_HUB_ID__c']))))"

 

I am starting end-to-end testing shortly.  I am sure  🙄  that I will discover more issues to contend with.

 

 

 

 

 

 

 

 

Using Azure Functions with Logic Apps – Part 1

There are times where you need to do data type conversions in a Logic App.

I recently ran into an issue where I was syncing records between CRMOL (on line) and Salesforce.  The record coming from CRMOL had NULL values.  When converted to JSON, the NULL value is a string.

I could use the Logic App  Replace function, but when you have to evaluate 30 to 50 fields, it becomes a tedious chore.

I decided to create a  Function App.  I used a C# Web Hook, so I can pass in the Response coming out of CRMOL.  I could return the parsed Record to be mapped to Salesforce.

The code is very simple. I loop through each field and replace the “NULL” values with a empty string.

In Part – 2,  I will show you the code and other utility functions  that can be used in Logic Apps.

 

 

 

Older posts
%d bloggers like this:
Skip to toolbar