Lynn
Lynn

Reputation: 4408

LogicApp that returns newly generated ID back to original source

Hello I am trying to create a LogicApp that first:

  1. Extracts data from CosmosDB, using a query

  2. Loops over the results

  3. Pushes the results data into CRM

Sidenote: Once this data is pushed into CRM, CRM automatically generates an ID for each record. How can I then:

  1. My biggest dilemma is figuring out how can I return the newly generated ID back to the original CosmosDB container in which it was pulled from?

I have started on this and these are my questions:

Does this first part look correct in what I am doing? I must use this SQL query for this:

a. I am simply telling the Logic App to extract data from a particular container inside CosmosDB

enter image description here

b. Then I would like to loop over the results I just obtained, and push this to CRM

enter image description here

c. My dilemma is:

Once data is pushed to CRM, CRM then automatically generates an ID for each record that is uploaded. How would I then return the updated ID to cosmos?

Should I create a variable that stores the IDS, then replace the old IDs with the new ones?

I am not sure how to construct/write this logic within LogicApps and have been researching examples of this.

Any help is greatly appreciated.

Thanks

Upvotes: 0

Views: 367

Answers (1)

mjonsing
mjonsing

Reputation: 74

If the call to your CRM system returns the ID you are talking about then I would just add one additional action in your loop in Azure Logic App to update the read record in Azure Cosmos DB. Given that you are doing a SELECT * from the container you should have the whole original document.

Add the 'Create or update document' action as a step with a reference to the THFeature container along with your Database ID and then provide the new values for the document. I pasted an example below.

enter image description here

BTW. Your select query looks strange - you should avoid slow cross partition queries if you can.

Upvotes: 1

Related Questions