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>