anusha(salesforce developer)

Thursday 15 September 2016

I need an Auto Number function when a specific value in the picklist is selected


Step 1:
Setup > Customize > Opportunity > Fields > Create New > Auto Number
-Save it but make sure that you remove the field from the page layout


Step 2:
Setup > Customize > Opportunity > Fields > Create New > Formula: Text
Just fill in the stage name literal of what you want in the below formula:

Create a custom formula (text type)
IF(ISPICKVAL(StageName , "A"), Auto_Number_Field__c , "")

Let me know if you run into any issues or if you want it to display w/ multiple criteria. Please note that when I say "display" I mean not have a blank/null value in the field.

Unfortunately there isnt a function that would create an autonumber based on an IF function (at least very easily). What I would suggest is this:

1) Create an autonumber custom field
2) Don't display it on the page layout
3) Create a custom formula that will contain your IF criteria.
IF( NOT(ISBLANK( Custom_Field__c)), Auto_Number_Field__c , null)
4) We would then display this formula on the page layout....basically it would show a value if the criteria were met.

Now, the thing to remember is that every record would be assigned the autonumber, but only under certain circumstances will the autonumber actually be displayed. Now if you are using this for reporting then you could create reports that would reflect your business logic. Let me know if you need more help creating any of the above!
I am doing this on the opportunity, and the picklist im referring is the Stage:
Step 1:
Setup > Customize > Opportunity > Fields > Create New > Auto Number
-Save it but make sure that you remove the field from the page layout


Step 2:
Setup > Customize > Opportunity > Fields > Create New > Formula: Text
Just fill in the stage name literal of what you want in the below formula:

Create a custom formula (text type)
IF(ISPICKVAL(StageName , "A"), Auto_Number_Field__c , "")

Let me know if you run into any issues or if you want it to display w/ multiple criteria. Please note that when I say "display" I mean not have a blank/null value in the field.

No comments:

Post a Comment