I have set up a ServiceEndpoint in Dynamics 365 to send messages to Azure Service Bus. Whenever there is an update on an Account Entity a message is queued. I have a service that is listening on this queue. My service is updating a property on the Account Entity that was queued.
My code is not executed as a plugin and does not implement IPlugin. This means that I do not have access to the IPluginExecutionContext. To avoid an infinite loop I would like to use the CorrelationId as a context for my update calls.
Is this possible?
This is what happens:
- Soemone updates or creates an account in Dynamics 365 Online
- my service on my local server receives the message from Azure Service Bus
- I parse the incomming JSON
- Verify that the Depth is not larger than 1 to avoid infinite loop
- I retreive the Account Entity from Dynamics
- I make an update on a custom field
- I update the Account Entity - Here is where it gets tricky! My update request is generating a new message with a different CorrelationId. I would like the update request to use the CorrelationId of the incomming message so that I do not find my self in an infinite loop.
My calls are using OrganizationServiceProxy