You need to sign in to do that
Don't have an account?

Trigger to update Quote Name with Custom Auto-Number Field
Hello,
I'm trying to hack my way around making the Quote Name auto-populate with a custom number field
Below is the trigger that does not work, I was only able to add a specific value into the Quote Name field.
I need the trigger to put the value of the custom quote auto-number field Quote_Number__c.
Any ideas? Thanks!
trigger QuoteTrigger on Quote (before insert) {
for(Quote q : Trigger.new) {
q.Name = q.Quote_Number__c;
}
}
Hi,
You should have after insert trigger. Below is the code you should have.
Let me know if you have any issues.
Imran,
After I applied the trigger, I tried to create a new quote, leaving the Quote Name empty, but since it's a required field, it asked me to enter a value, so I did and recieved this error message:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger QuoteTrigger caused an unexpected exception, contact your administrator: QuoteTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.QuoteTrigger: line 6, column 1
I wish it was as simple as changing the Quote Name to an auto-number field. This is possible with Custom Objects. I need the Quote Name to populate with a custom number, that's why I created a custom auto-number field with the attempt to link it to the Quote Name. I don't want the user to worry about entering anything in the Quote Name.
Jeremy
Hi Jeremy
You cannot update the record you are evaluating in after triggers. You best option for this would be to use Workflow to populate this field (additional advantages to this solution is you do not need any test code, or if you decide you no longer what to rename your quotes, you can easily disable).
Hope this helps
Ealesie