You need to sign in to do that
Don't have an account?
Getting the quote number of the Synced Quote for a Trigger on Opportunity
Hi,
I have a Custom Object Order.
I have am coding a Trigger to create an order automatically after an opportunity is won and I want to the order name to be automatically assigned the Synced quote number of the related opportunity.
Here's the code I have :
trigger test2 on Opportunity (after insert, after update) {
for (Opportunity b : Trigger.new){
List<Order__c> aa = [SELECT Id, Name FROM Order__c WHERE Opportunity__c = :b.Id];
Integer i = aa.size();
If (b.StageName == 'Closed Won' && i==0) {
Order__c a = new Order__c();
insert a;
a.Name = b.SyncedQuote.QuoteNumber;
a.Opportunity__c = b.Id;
update a;
}
}
}
My issue is that the code in blue does not give me the Quote number but some Salesforce ID that I don't understand like "a02e0000001ivSG".
Can someone tell me how to get the quote number?