You need to sign in to do that
Don't have an account?
Amita Tatar
Create a new opportunity on button click and insert data from a custom object
Hi all,
I have lead object and its child object.I want to create new opportunity from each record in the related list of child object. How can i do that ?
While creation of opportunity, i want to check if Account for that lead exists or not,else create it first and then create opportunity and insert data from the child object.How can i do so? I have started writing below trigger for the same.
Thanks,
Amita Tatar
I have lead object and its child object.I want to create new opportunity from each record in the related list of child object. How can i do that ?
While creation of opportunity, i want to check if Account for that lead exists or not,else create it first and then create opportunity and insert data from the child object.How can i do so? I have started writing below trigger for the same.
Thanks,
Amita Tatar
trigger CreateOpportunity on Existing_Policies__c (before update) { public List<Opportunity> oppList= new List<Opportunity>(); for(Existing_Policies__c e: trigger.new){ Opportunity o = new Opportunity(); o.Name = e.Lead__c; o.AccountId = e.Lead__r.Company; o.CloseDate = Date.Today(); o.Loss_Reason__c = 'Closed Lost'; o.StageName= 'Closed Won'; o.Insured_via_Gauntlet__c = e.Insured_via_Gauntlet__c; o.Cover_not_applicable__c = e.Cover_not_applicable__c; o.Chose_not_to_take_cover__c = e.Chose_not_to_take_cover__c; o.Policy_Type3__c = e.Policy_type__c; o.Insured_Elsewhere__c = e.Insured_Elsewhere__c; o.Notes_Comments__c = e.Notes_Comments__c; o.Current_Broker__c = e.Current_Broker__c; o.Current_Insurer__c = e.Current_Insurer__c; o.Quotation_Requested__c = e.Quotation_Requested__c; o.Renewal_Date__c = e.Renewal_Date__c; oppList.add(o); } insert oppList; }