A new Quote assigns "Q-NNNNN" value to a newly generated quote. We want to assign value of opportunity number to a newly generated quote. For instance the Quote number will look something similar to "Q--1". Is it possible to do this?
This is possible on the standard
Quote object. What's more, you can even do it declaratively!
Workflow to the rescue
You can create a workflow rule that only runs when a new record is inserted. Set it to run on all newly inserted
Quotes by choosing the option to use a formula to use as the workflow rule criteria, and simply put
true into the formula window.
Then, create a workflow field update, and choose
Quote Name as the field to update.
Click the little radio button to use a formula to set the value of the field. The formula that you'll use is pretty simple, and should look something like this:
'Q-' & Opportunity.Opportunity_Number__c & '-' & NOW()
Note that there isn't a standard 'Opportunity Number' field. I used the field name from my org. If yours is different, you'll need to modify the formula accordingly.
& in the formula is used to concatenate strings.
Sequential quote numbers that start over from 1 on each new
Opportunity complicates things slightly.
NOW() returns the current date and time, which should be sufficiently unique.
Having an auto-number field on the Quote is an option, but you wouldn't be able to start over from 1 for the first
Quote on subsequent
Opportunities (it would keep incrementing, just like an Opportunity number)
But I reeeeeeally want sequential quote numbers
If you really want sequentially numbered
Quotes on each
Q-<Opp Number>-2, and so on, it certainly is possible, but requires a bit more work. Still no code required, though.
Create a new rollup summary field on
Opportunity that counts the number of quotes. For sake of example, I'll call this field
Keeping in mind the order of execution,
Num_Quotes__c will not be updated until after this workflow rule fires. That means to get the proper quote number, you'll need to add 1 to
The example formula becomes:
'Q-' & Opportunity.Opportunity_Number__c & '-' & (Opportunity.Num_Quotes__c + 1)