In this scenario we were asked to demonstrate how to create a Comma Separated list within a N52 Formula.
To do this we use a SmartFlow.
In this example we will retrieve a list of Account numbers in CRM starting with the letter T.
N52 Formula Manager Solution
The Formula Manager solution works like this,
- A formula of type 'Save - To Current Record' is created on the Account entity
- For demonstration purposes the Source Property for this formula is 'Account Name'
- The Target Property is set to the 'Description'
- We create a Variable called CSVList to hold all the 'Account Numbers'
- We then use FetchXML to find all the Accounts where the Account Number starts with T
- For each account found, we add the Account Number and a comma to the CSVList variable
- When all the Account Numbers have been added we use the Trim function to remove the last comma and then return the value of the CSVList
N52 Formula Manager Steps
The following set of steps outline how to create this Formula
- Create a new formula of type 'Save - To Current Record'
- Set the Source Entity to 'Account'
- Set the Mode to 'Server Side'
- Copy and paste the formula below into the formula
- Click save and test
SmartFlow( SetVar('CSV', ''), ForEachRecord( FindRecordsFD('FindTAccounts', true), SetVar('CSV', GetVar('CSV') + CurrentRecord('accountnumber') + ',')), SetVar('CSV', Left(GetVar('CSV'), CountCharacters(GetVar('CSV')) -1)), SmartFlowReturn(GetVar('CSV')) )
Fetch XML- FindTAccounts
<fetch count="50" > <entity name="account" > <attribute name="accountnumber" /> <filter> <condition attribute="accountnumber" operator="begins-with" value="T" /> </filter> </entity> </fetch>
Wizard - FindRecordsFD
Did you know?
xCache helps you manage environment specific configuration
North52's Decision Suite component xCache allows you to set up environment specific data to allow you to use different values for different instances. Your advanced business rules logic could be the same, however you need to use specific reference values for a particular instance.
For example, credentials for a web service used in your Formula - you will likely use different keys/URLs for your Dev, Test and Production instances. Store these in xCache and let the North52 business rules engine apply the correct ones at runtime!