Overview
In this scenario, we have a formula that prefixes the AutoNumber with the year. We would like this AutoNumber value to be reset at the start of each year so that users can see the number of accounts been made this year.
North52 Decision Suite
The North52 Decision Suite solution works like this:
- A Formula is created that calculates and sets the AutoNumber
- A Workflow is created that will reset the AutoNumber value to 0
- A Schedule is set up to run yearly that executes the Workflow
Set up Formula, Workflow and Schedule
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 Auto Number
- Select the Classic Editor
- Change the Name of the formula to Set Account Number
- Expand Source & Target
- Set Target Property to Account Number
- Click Save
- Paste the following code into the Classic Editor
(ToString([account.createdon], 'yy') + '-' + PadLeft(ToString(AutoNumber([account.accountnumber]+1)),6,'0'))
- Click Save
Workflow
- Navigate to Settings > Processes
- Create a new process, setting the following values:
- Process Name set to AutoNumber reset
- Set Category to Workflow
- Set Entity to N52 Formula
- Click OK
- Untick Record is created
- Tick As an on-demand process
- Click Add Step > Update Record
- Click on Set Properties
- Scroll down and expand N52 System Settings
- Find Auto No.Value and enter 0 in its field.
- Click Save and Close
- Click Save
- Click Activate
Schedule
- Navigate to Settings > N52 Schedule
- Create a new Schedule:
- Set Name to Reset AutoNumber
- Set Frequency to Yearly
- Set Schedule Type to Workflow
- Set Workflow to the name of your Workflow (AutoNumber reset in this example)
- Set the Start DateTime to the date and time you wish the AutoNumber to be reset
- For Fetch Xml Query copy and paste the following Fetch Xml:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> <entity name="north52_formula"> <attribute name="north52_autonumbervalue" /> <order attribute="createdon" descending="true" /> <filter type="and"> <condition attribute="north52_shortcode" operator="eq" value="UMQ" /> </filter> </entity> </fetch>
- Click Save
- Select N52 Commands > Start Schedule
Test
You are now ready to test. To Test the formula, create a new Account. You should see that the AutoNumber is set.To test the Schedule, set the Next Run DateTime on the Schedule to be some time soon, you can see the Workflow firing and resetting the AutoNumber of the formula.