Monday, October 17, 2016

Message Listener with No Code Json Parsing

In this post I am going to show how you can configure a message listener in Dynamics CRM that will receive Json messages, parse the Json and create a record using the parsed data We are going to do all of this without any custom code.

First a bit of background on an unused corner of Dynamics CRM. Every activity record has a field called Additional Parameters which is designed to hold a Json payload. This is used by apps like Microsoft Social Engagement to automatically create CRM records from social media posts. The Json in the Additional Parameters field can be parsed and extracted by the record creation Rules.

We are going to create a record creation rule to create a contact record when an email is received by a queue and the rule will parse the Additional Parameter's Json and use the Json data to populate the contact fields. By using an email queue as our message transport mechanism we have ready made message listener. Details on how to create an email queue with an Office 365 shared mailbox here


As the emails are originating from an external system they don't have an Additional Parameters field so instead the Json payload goes in the subject line. A workflow is required to copy the subject line into the Additional Parameters field when the email is created.




Now create a record creation rule under service management that will parse the Json and create a contact record. The Json parsing is configured in the Channel Properties section by creating a Channel Property Group.



In the Channel properties you create a property for each data item to you want to parse. Each item gets a name and I found I had some problems if the name and application source did not match.




Now when you configure the record creation rule the channel properties are available for selection




Now  I can send an email to my queue with the Json in the subject line




The record creation rule will create a contact from the Json. No code just configuration.

























2 comments:

  1. We have tried the same solution (CRM 8.2 Online) with emails directly to the queue and any workflow or even plugin, blocks the email creation and no JSON is copied from subject or email body description to additional parameters attribute. I cannot see how you have successfully achieved this solution. The timing from email creation in the queue and the channel properties being picked up from the JSON string occurs before any workflow or plugin executes.

    ReplyDelete
    Replies
    1. Hi Whitey, Are you saying the the step "A workflow is required to copy the subject line into the Additional Parameters field when the email is created." did not work for you? so there was not json when it hit the queue

      Joe

      Delete