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 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.