web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

How to Use FLOW (Power Automate) to get Entity ID via ODATA

(1) ShareShare
ReportReport
Posted on by 1,589

I have a flow that changes ownership on records that are returned as the result of a series of fetch xml queries.

The problem I have is that the note (annotation) record can be related to three different record types via the regarding object type field. 

  • my_customestimate
  • my_customjob
  • my_customsetting

The entity type number does not appear to return via Fetch XML making it difficult to build a flow whose fetch xml query gets data if objecttypecode = 'my_customjob'

What seems to be returned is the name of the entity, but that doesn't seem to work as a mechanism of comparison in the fetch xml. 

What does work, is if I set if objecttypecode = 10272 

The problem is the actual number is different in every D365 instance we have, so I need a way to dynamically obtain it, and then put it in a variable. 

I understand that if I use the following WebAPI ODATA Query: https://myinstance.crm.dynamics.com/api/data/v9.1/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName%20eq%20%27my_customjob%27

The following JSON Data is returned: 

{"@odata.context":""value":[{"ObjectTypeCode":10272,"MetadataId":"149c20d3-08ec-465c-8965-734db77a6c2c"}]}">myinstance.crm.dynamics.com/.../$metadata

And the 10272 is what I need to get into a variable so that when the same flow is run across 5 different D365 Online environments, it works regardless of what the actual number is of the object type code. 

I have a variable that holds the current instance's WepAPI ODATA Query which is https://myinstance.crm.dynamics.com/api/data/v9.1/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName%20eq%20%27my_customjob%27 

If this was myinstance2 -- the first part if the URL stored in the variable would bhttps://myinstance2.crm.dynamics.com/api/data/v9.1/EntityDefinitions?$select=ObjectTypeCode&$filter=SchemaName%20eq%20%27my_customjob%27 so I am good with that part. 

What I can't figure out how to do is to "Execute" the WebAPI ODATA Query, then Receive the Return JSON data and extract the value of Object Type Code (which in the example above is 10272) into a variable within Power Automate (Flow). 

Any help, advice, guidance, or directly would be greatly appreciated. 

I have the same question (0)
  • ACECORP Profile Picture
    1,589 on at
    RE: How to Use FLOW (Power Automate) to get Entity ID via ODATA

    I was able to figure out 50% of it and now just need a little nudge over the top of the hill.

    I have an Invoke HTTP Object running and getting the JSON as shown below.

    HTTTPGET.png

    The actual complete output is shown below.

    {
      "@odata.context": "https://mycrminstance.crm.dynamics.com/api/data/v9.1/$metadata#EntityDefinitions(ObjectTypeCode)",
      "value": [
        {
          "ObjectTypeCode": 10272,
          "MetadataId": "149c20d3-08ec-465c-8965-734db77a6c2c"
        }
      ]
    }

    I then have a Parse JSON object configured to pull the data from the output as shown.

    8461.ParsedJSON.png

    The full JSON template that's present in the parse JSON object above is:

    {
        "type": "object",
        "properties": {
            "@@odata.context": {
                "type": "string"
            },
            "value": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "ObjectTypeCode": {
                            "type": "integer"
                        },
                        "MetadataId": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "ObjectTypeCode",
                        "MetadataId"
                    ]
                }
            }
        }
    }

    However, the Parse JSON Object errors out as shown below.

    PJSONError.png

    The text of the error message is:

    Unable to process template language expressions in action 'Parse_JSON_GET_Request_(HTTP)_ObjectTypeID(Job)_URL' inputs at line '1' and column '127968': 'Required property 'content' expects a value but got null. Path ''.'.

    Where am I going wrong?

  • ACECORP Profile Picture
    1,589 on at
    RE: How to Use FLOW (Power Automate) to get Entity ID via ODATA

    Wow, it all of a sudden started working properly with absolutely no modifications on my end.

    Given that fact, it seems I am now 99% of the way to the goal, with the only missing objective being:

    How can I extract a very specific portion of the result of the parsed JSON and place it in an integer variable so I can use it in other flows?

    Specifically I want to take the ObjectTypeCode value of 10255 and place the 10255 in an integer variable so I can use it in other flows?

    ResultOfParsedJSON.png

  • Suggested answer
    ACECORP Profile Picture
    1,589 on at
    RE: How to Use FLOW (Power Automate) to get Entity ID via ODATA

    This has now been successfully completed. I will post the details of what I did for the benefit of others who are looking to do the same thing.

    The Parse JSON Object is correct, and the next step was to initialize a new variable as shown below.

    Then once the variable was initialized, the next step was to the value pulled from the JSON Parse Object to Set the value of the variable equal to the Object Type Code as shown below.

    SetVariable.png

    Once done, and the flow runs, it does indeed assign the type code to the desired variable thus allowing me to use entity type codes dynamically in child/related flows.

    ResultSetVariable.png

  • CD-09081632-0 Profile Picture
    2 on at
    How to Use FLOW (Power Automate) to get Entity ID via ODATA
    Share your entire Power Automate screen shots in the order of execution and I will take a stab at it
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 120

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 120 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 56

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans