Views:

Overview

The business requirement is to create a custom JSON message whenever certain fields change on the Account record. This JSON message then had to be sent to our Azure Event Grid.

The custom message needs to contain certain fields on the Account record and certain fields for all child Contact records.

Note: This article presumes you already have Azures Event Grid setup for your Azure subscription. For details on how to do this please see the Microsoft documentation

North52 Decision Suite

The North52 Decision Suite solution works like this:

  • A formula is created that will trigger whenever the following fields are changed on a Account record:
    • Account Name, Account Number, Address 1: Street 1, Address 1: Street 2, Address 1: Street 3, Address 1: City, Address 1: ZIP/Postal Code, Address 1: State/Province, Address 1: Country
  • This formula will create a JSON object with properties of the same fields
  • This formula will also find all child Contacts of this Account and add the following fields to the JSON Object:
    • Full Name, Job Title, Email, Business Phone
  • The Formula will then send this JSON message to the Azure Event Grid

Setup Formula

  • Navigate to Settings > N52 Formula
  • Create a new formula, setting the following values in the Formula Guide:
    • Source Entity set to Account
    • Set Formula Type to Save - Perform Action
    • Select the Classic Editor
    • Change the Name of the formula to Account Data Change - Send Message to Azure Event Queue
    • Expand Source & Target
    • Under Source Property, Ctrl-click the following fields:
      • Account Name, Account Number, Address 1: Street 1, Address 1: Street 2, Address 1: Street 3, Address 1: City, Address 1: ZIP/Postal Code, Address 1: State/Province, Address 1: Country
  • Copy and paste the following into the Classic Editor (Note: you will need to change the parameters inside AzureEventGridSendMessage with your own Azure details)
    SmartFlow(  
      
      SetVar('JsonMessage', 
       CreateJObject(
                       CreateJProperty('AccountName',         [account.name], ''),
                       CreateJProperty('AccountNumber',     [account.accountnumber], ''),  
                       CreateJProperty('Address_Line1',     [account.address1_line1], ''),
                       CreateJProperty('Address_Line2',     [account.address1_line2], ''),
                       CreateJProperty('Address_Line3',     [account.address1_line3], ''),
                       CreateJProperty('Address_City',         [account.address1_city], ''),
                       CreateJProperty('Address_Zip',         [account.address1_postalcode], ''),  
                       CreateJProperty('Address_State',     [account.address1_stateorprovince], ''),  
                       CreateJProperty('Address_Country',     [account.address1_country], ''),
                    
                       CreateJProperty('Contacts', 
                                    CreateJArrayChildren(
                                             FindRecords('contact', 'parentcustomerid', [account.accountid], '*' ),
                                             CreateJObject(
                                                           CreateJProperty('Fullname', FindJArrayItem('fullname')),
                                                           CreateJProperty('Jobtitle', FindJArrayItem('jobtitle')), 
                                                           CreateJProperty('Email', FindJArrayItem('emailaddress1')),
                                                           CreateJProperty('BusinessPhone', FindJArrayItem('telephone1'))
                                                                     ) ))
                         ) 
      ),
    
      AzureEventGridSendMessage(
        'https://north52-eventgrid.servicebus.windows.net/north52eventgridqueue/messages',
        'RootManageSharedAccessKey',
        '2ol67s0u7//z6u0nR4t3UnEfue36+xBjnedQNEHWSqK',                   
        'https://north52-eventgrid.servicebus.windows.net',
        'json',
        GetVar('JsonMessage'))
    
    )
  • Click Save

Test

You are now ready to test. To test the formula, open up an Account record and change one of the fields that triggers the formula - e.g. Account NameAccount Number, or one of the relevant address fields. 

Go to your Azure Event Grid and you should see something like this:

After the message is sent to the queue, this is what it looks like in the Storage Explorer for the Event Grid:

Did you know?

North52 has a powerful distributed cache for advanced decision logic

xCache allows you to configure and scale your Dynamics 365/CRM applications running On-Premise or Online. It allows dynamic system configuration and removes performance bottlenecks related to data storage. xCache provides Dynamics 365/CRM with an extremely fast and scalable distributed cache to power your advanced decision logic.

xCache in Dynamics CRM  lets you cache static application data, and also load dynamic cache items for applications running in a single or multi-server configuration.

Learn more and see examples of xCache