Skip to main content
Edited question as It adresses someting different
Source Link
Jenssen
  • 439
  • 3
  • 9
  • 31

Is it possible to for example pre fill/pre-populate field of an Quote with field values of an opportunity so the user can see the populated fiels before saving, since the Id is generated after insert? I tried the following with no success:

trigger trgQuoteOpp on Quote (before insert) {
    for(Quote a : Trigger.New) {
        Id quoteId = a.Id;
        if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id;
                          System.debug(OppId);
                          }
        System.debug(quoteId);  
    } 
}

Is it possible to for example pre fill field of an Quote with field values of an opportunity, since the Id is generated after insert? I tried the following with no success:

trigger trgQuoteOpp on Quote (before insert) {
    for(Quote a : Trigger.New) {
        Id quoteId = a.Id;
        if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id;
                          System.debug(OppId);
                          }
        System.debug(quoteId);  
    } 
}

Is it possible to for example pre fill/pre-populate field of an Quote with field values of an opportunity so the user can see the populated fiels before saving, since the Id is generated after insert? I tried the following with no success:

trigger trgQuoteOpp on Quote (before insert) {
    for(Quote a : Trigger.New) {
        Id quoteId = a.Id;
        if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id;
                          System.debug(OppId);
                          }
        System.debug(quoteId);  
    } 
}
Post Closed as "Duplicate" by Adrian Larson apex
added 39 characters in body; edited tags
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

Is it possible to for example pre fill field of an Quote with field values of an opportunity, since the Id is generated after insert? I tried the following with no successuccess: trigger trgQuoteOpp on Quote (before insert) { for(Quote a : Trigger.New) { Id quoteId = a.Id; if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id; System.debug(OppId); } System.debug(quoteId); } }

trigger trgQuoteOpp on Quote (before insert) {
    for(Quote a : Trigger.New) {
        Id quoteId = a.Id;
        if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id;
                          System.debug(OppId);
                          }
        System.debug(quoteId);  
    } 
}

Is it possible to for example pre fill field of an Quote with field values of an opportunity, since the Id is generated after insert I tried the following with no succes: trigger trgQuoteOpp on Quote (before insert) { for(Quote a : Trigger.New) { Id quoteId = a.Id; if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id; System.debug(OppId); } System.debug(quoteId); } }

Is it possible to for example pre fill field of an Quote with field values of an opportunity, since the Id is generated after insert? I tried the following with no success:

trigger trgQuoteOpp on Quote (before insert) {
    for(Quote a : Trigger.New) {
        Id quoteId = a.Id;
        if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id;
                          System.debug(OppId);
                          }
        System.debug(quoteId);  
    } 
}
Source Link
Jenssen
  • 439
  • 3
  • 9
  • 31

Is it possible to use a before trigger to pre-fill fields?

Is it possible to for example pre fill field of an Quote with field values of an opportunity, since the Id is generated after insert I tried the following with no succes: trigger trgQuoteOpp on Quote (before insert) { for(Quote a : Trigger.New) { Id quoteId = a.Id; if(quoteId !=null){Id OppId=[SELECT OpportunityId FROM Quote WHERE Id =:quoteId ORDER by Name].Id; System.debug(OppId); } System.debug(quoteId); } }