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?

  • A trigger on Quote would be needed to do this – coderdecoder Sep 28 '16 at 19:10
  • If you are using standard object.you can't do it a direct way.(or) create a custom field in quote object – Pavan tej Sep 28 '16 at 19:36

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.

The ampersand & 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 Opportunity, e.g. Q-<Opp Number>-1, 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 Num_Quotes__c

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 Num_Quotes__c.

The example formula becomes:

'Q-' & Opportunity.Opportunity_Number__c & '-' & (Opportunity.Num_Quotes__c + 1)

  • Derek, Pavan, Ankit, Thanks a lot for your replies. I was able to change quote number in standard quote with the help of trigger. – vetal_king Oct 4 '16 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.