This is a compact version, please ask if you need clarifications:
I have managed to register an endpoint so that when I update a property (for example phone number) in Dynamics CRM Online a message is sent to Azure Service Bus (topic and/or queue, no difference here). I also have a webjob that listens to theses changes, using the signature below:
public static void ProcessTopicMessage([ServiceBusTrigger("my-crm-topic", "topic-subscription1" )] BrokeredMessage pQueueItem, TextWriter log) { RemoteExecutionContext package = pQueueItem.GetBody<RemoteExecutionContext>(); if(package.MessageName == "Update") { Entity entity = pPackage.InputParameters["Target"] as Entity; var newPhone = entity.GetAttributeValue<string("telephone1"); } ... }
This works ok, when I change for example phone number I can read the new phone number and all other properties are null. HOWEVER, I cant find any information on the name/id of the property/properties that were changed (except that they are not null).
I could loop through all property names and be happy with that, but the main problem is that there no way to know if the property was set back to null from something else.
I cannot find any indication of that its the phone number that has been changed in pQueueItem- or package-properties. Where do I find it?
*This post is locked for comments
You are my hero :), I didnt check there, just indexed with property names that I knew of. As you pointed out, the Attributes-array contains the updated property/ies, along with four properties that always are there. Thanks a bunch!
Hi,
in your "target" entity, (Entity entity = pPackage.InputParameters["Target"] as Entity)
you have collection of attributes. Those are the only attributes that were changed (either set to null or initialized with some value). Looping through this collection would provide you with what you need.
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156