You need to sign in to do that
Don't have an account?
Radhe Shyam.
Create parent record from child trigger then populate on child
Hi DEVs,
I have Quote(child) and opportunity(parent).
I need to create Opportunity if Quote is created. AND then need to populate same oppty on Quote.
I have done half task, created oppty from Quote Trigger on After Insert. But now challange how to populate this back on quote In bulkify way.
I am missing somthing that how we will keep track of quote wise oppty created??
Please guide.
Here is my code.
Thanks
I have Quote(child) and opportunity(parent).
I need to create Opportunity if Quote is created. AND then need to populate same oppty on Quote.
I have done half task, created oppty from Quote Trigger on After Insert. But now challange how to populate this back on quote In bulkify way.
I am missing somthing that how we will keep track of quote wise oppty created??
Please guide.
Here is my code.
//Handler for Quote Trigger public class QuoteTriggerHandler{ public static void AfterInsertActions(List<Quote> lstQuotes){ System.debug('Hello Trigger After Insert'); List<opportunity> lstOppToInsert = new list<opportunity>(); //Iterate loop over all new created records of Quote try{ for(Quote eachQuote : lstQuotes){ //Create instanse Opportunity opp = new opportunity(); opp.Name = eachQuote.Name; opp.StageName= 'Closed Won'; opp.Amount= 100; //This will be calculated and overrited automaticlly form oppty lines's price sum. We just need to populate dummy as it is required field. opp.CurrencyIsoCode= eachQuote.CurrencyIsoCode; opp.AccountId= eachQuote.AccountId; opp.CloseDate= System.Today();//eachQuote.Name; opp.ForecastCategoryName= 'Closed'; opp.OwnerId= eachQuote.OwnerId; lstOppToInsert.add(opp); } if(lstOppToInsert!=null && lstOppToInsert.size()>0){ Database.SaveResult[] srList = Database.insert(lstOppToInsert, false); System.debug('lstOppToInsert '+lstOppToInsert); } }catch(Exception e){ System.debug('Error '+e.getMessage()); } //Once Opportunity has been inserted, Populate Same opportunity on quote // } }
Thanks
You need to create an inline vf page on Quote to display the Opportunites associated with a Quote. In that inline Vf page you just need to fetch and display the opportunities associated with the Quote.
Thanks
Ajay
I am looking for bulk record creation.
Will upload data from csv and then these thing should happen.
I have found one way, please let me know if i can do some optimization in this.
1. in above code, i made few change and capturing the Quote id on opportunity.
2. written trigger on Opportunity on after insert: Here is code - please suggest where i can do optimization if required.
This code is working fine.
Thanks
Radhe S