Overview
The business requirement was to create a custom JSON message whenever certain fields change on the Account record. This JSON message then had to be sent to our Service Bus queue.
The custom message needs to contain certain fields on the Account record and certain fields for all child Contact records.
Note: This KB article presumes you already have the service Bus Queue already 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
- This formula will create a JSON object with properties of 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
- This formula will also find all child Contacts of this Account and add their following fields to the JSON Object:
- Full Name, Job Title, Email, Business Phone
- The Formula will then send this JSON message to the Azure service Bus
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 Service Bus 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 AzureServiceBusSendMessage 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')) ) )) ) ), AzureServiceBusSendMessage( 'https://n52bpa-sb-north52v2.servicebus.windows.net/n52bpa/messages', 'RootManageSharedAccessKey', 'HKutpMU25diCyJyl5X0BO5sYw8nfkx6gI1VyppEFAII=', 'https://n52bpa-sb-north52v2.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 Name, Account Number, or one of the relevant address fields.
Go to your Azure queue and you should see something like this:
After the message is sent to the queue, this is what it looks like in the Service Bus Explorer: