function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Laetitia Damen 9Laetitia Damen 9 

Auto-populate the opportunity name field !

Hi there!
I'm looking for a solution about that case =>
When an opportunity is created, the name must have the following format: Automatic Number – Account Name – Creation Date.
Any advices?  :)
Best Answer chosen by Laetitia Damen 9
Maharajan CMaharajan C
HI Laetitia ,

I hope you have created the Auto Number field in Opportunity object.

You can use the process builder for this scenario.  In before insert trigger the auto number will be empty so you can use the apex trigger.

Please follow the below stpes:

User-added image
User-added image
User-added image
User-added image
User-added image


Forumula :   (Opportunity_Number__c --> my Auto Number Field)

[Opportunity].Opportunity_Number__c  &  ' - ' & [Opportunity].Account.Name  & ' - ' &  TEXT(DATEVALUE([Opportunity].CreatedDate ))


Thanks,
Maharajan.C

All Answers

AbhinavAbhinav (Salesforce Developers) 
By  Automatic Number you mean any random number?
Laetitia Damen 9Laetitia Damen 9
yes and I've created a custom field  "opportunity number" so I would like to set up all these Infos for the Op name. 
AbhinavAbhinav (Salesforce Developers) 
Hi Laetitia ,

I think you can use before insert trigger for this to update the Name field.

You can get reference from below link and modify accordingly  as per you use case.

https://developer.salesforce.com/forums/?id=906F0000000kAqTIAU

Thanks!
Maharajan CMaharajan C
HI Laetitia ,

I hope you have created the Auto Number field in Opportunity object.

You can use the process builder for this scenario.  In before insert trigger the auto number will be empty so you can use the apex trigger.

Please follow the below stpes:

User-added image
User-added image
User-added image
User-added image
User-added image


Forumula :   (Opportunity_Number__c --> my Auto Number Field)

[Opportunity].Opportunity_Number__c  &  ' - ' & [Opportunity].Account.Name  & ' - ' &  TEXT(DATEVALUE([Opportunity].CreatedDate ))


Thanks,
Maharajan.C
This was selected as the best answer
Charles Thompson 17Charles Thompson 17
Record Triggered Flow is the way forward!  Thanks for posting, @abhinav!