Views:

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 
  • 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. 


 

Did you know?

North52 has over 500 functions to help you implement advanced business rules and complex decision logic

One of the biggest costs on most Microsoft Dynamics 365/CRM project is custom coding. This is where consultants or developers are invloved in writing 100’s if not thousand’s of lines of code in Javascript and/or C#.

The Formula Manager, part of the North52 Decision Suite is a business rules engine that aims to eliminate this custom coding by using simple formulas instead. It is significantly faster (up to 10 times) than writing custom code and you get the added bonus of lower cost updates if a business rule changes in the future (it is much faster and thus cheaper to change it using a Formula rather than custom code).

There are over 500 functions available in the North52 Decision Suite business rules engine!

Learn more about North52 Business Process Activities