In this scenario we will show you how to set up an AutoNumber formula on an Opportunity entity that only fire only when the Opportunity reaches a specific stage in the Business Process.
The requirement is that we only want to set the AutoNumber when the Opportunity reaches the Develop stage. For this example I have created a custom field on the Opportunity entity called Opportunity ID that will store the identification autonumber.
N52 Formula Manager Solution
The Formula Manager solution works like this,
- A Formula of type 'AutoNumber' is created on the Opportunity entity
- Event is set to 'Update'
- Source Property is set to 'Process Stage'
- The Target Property is set to 'Opportunity ID'
- The DoesNotContainData() function ensures that the field doesn't get updated again if the Opportunity is set to the Develop stage on more than 1 occasion during its life cycle.
N52 Formula Manager Steps
The following set of steps outline how to create this Formula
- Create a formula of type 'AutoNumber' on the Opportunity entity
- Set the Source Properties as 'Process Stage'
- Set the Target Property as 'Opportunity ID'
- Copy and paste the formula below into the formula canvas
- Save and test!
If([opportunity.stageid.stagecategory.?] = 1 and DoesNotContainData(FindValue('opportunity', 'opportunityid', [opportunity.opportunityid], 'new_opportunityid', '?', true)) , /* True */ 'Opp-' + PadLeft(ToString(AutoNumber([opportunity.new_opportunityid] + 1)),9,'0'), /* False */ 'NoOp' )
Wizard - FindValue
Please see below the wizard you can use to create the FindValue() function call used in this formula.
Note to find the value for Equals Value , you will need to go to the Source tab and find Opportunity.
Did you know?
About North52's four A’s of automated software testing?
Assemble. Arrange. Act. Assert.®
TestShield is a testing solution for Dynamics 365/CRM which covers what we call the “four A’s of automated software testing“:
- Assemble – describe the feature or process that you are testing using Gherkin language
- Arrange – TestShield helps you automate the creation of test data – simply select from existing records plus their related records and TestShield will automatically arrange a ‘slice’ of your test data based on your selection
- Act – easily define the processes you wish to trigger as part of your test
- Assert – define the expected results