Search code examples
dynamics-crmazure-cosmosdbazure-data-factoryazure-logic-appspower-automate

Recognize 'lookup' ID's (CRM) according to values in CosmosDB and set it into a Logic App


Background:

I have data coming from CosmosDB that needs to be pushed into CRM. I am using a LogicApp for this.

Dilemma:

There are multiple IDs that have different attributes associated with them: For instance the 'ems_featurecategoryid'. Each has a different name that goes along with its unique ID. (This the raw data that is within CRM)

Figure A Figure A

Here is the CRM interface and the lookup field (feature category) in which I wish to push the CosmosDB data into:

Figure B enter image description here

Here is the CosmosDB data that hold this FeatureCategory attribute:

Figure C

enter image description here

There are over 3000 of these. How would I map the IDs that are within CRM (Figure A) with CosmosDB (Figure C), so that when a value input is provided to the Feature Category lookup in CRM, this is recognized according to the value in CosmosDB?

This is what I am thinking:

I provided the Logic App with one of the GUIDs from Figure A. I am not sure if this is the right thing to do. The value is pushed through, but how do I account for all of the others?

Any help or suggestions are appreciated.

enter image description here

enter image description here


Solution

  • If I understand your question correct, You have Id's and it's respective name coming from CosmoDB.

    In turn these Id's and unique name are feature category records(unique), I am not sure what entity name it has. Now you wish for your Entity Features update record with it's field Feature Category(Lookup field) with the data coming from Cosmo DB.

    You cannot directly update lookup field of a record with it's ID.

    Follow the link here to set lookup

    For a contact lookup you do it as

    contacts(<ContactID>)
    

    So how do you set Feature Category field, As mentioned in link above you do it as

    pluralSchemaname(YourGuidFromCosmoDB)
    

    If this does not work for you, then I would say, use Get Record Action of power automate/logic app,

    So get your Feature entity record as below, Record Identifier would be a Guid you will get from Cosmo DB.

    Now you get Feature lookup record and you can use this record to update field Feature in your entity Features.

    enter image description here