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.
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 be https://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.
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.
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.
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?
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.
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.
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.
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?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,101 Super User 2024 Season 2
Martin Dráb 229,896 Most Valuable Professional
nmaenpaa 101,156