Pages

Tuesday, May 14, 2013

Salesforce: Roll-Up Summary field for running number


Few days ago, when following Salesforce Community conversation, a member asked for running number in  Opportunity based on Account Number.

Using trigger, this is not an issue at all. A trigger in Opportunity on create and update will work perfectly. But, not every salesforce.com admin is familiar with apex code which usually do by a Salesforce.com developer.

Is is possible just using configuration, point and click without coding?
YES, here we go:

1. Create roll-up summary field in Account 
Filter Criteria = All records should be included in the calculation
You can hide this field from page layout.
It will hold number of opportunity for that Account.
Example: Number of Opportunities













2. Create a text field in Opportunity
This field will show the Account Number + running number.
Let's say Account Number = SF-0100, the first Opportunity will have Tracking Number = SF-0100-1, the second will be SF-0100-2 and etc.
Example: Tracking Number


3. Create a workflow in Opportunity
Just make sure, Evaluation Criteria = created and Rule Criteria = true







4. Create a field update in Opportunity
The formula would be:
Account.AccountNumber +'-'+ TEXT(Account.Number_of_Opportunities__c+1)







Drawback:
Issue will arise if any opportunity created earlier get deleted. Running number in opportunity will keep running, except the opportunity deleted is the last opportunity.

2 comments:

  1. Really enjoying your blog - great workaround idea's and inventive formula's. Thank you!

    ReplyDelete
  2. I am so happy I found your Blog - very creative & inventive workarounds & Formula's. I have been working with SF for 7 years and still learn something new almost every day because of the community and people like you. Thanks!

    ReplyDelete

Page-level ad