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
Pascal TPascal T 

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?