You need to sign in to do that
Don't have an account?

test class for lead conversion on opportunity update
Hi,
I wrote a trigger on lead which will fire when lead is converted and opportunity contact gets updated. trigger is working fine I need to create a test class for deployment
Below is the trigger which i wrote and i dont see any code coverage please suggest me how to make the changes.
Thanks
Sudhir
I wrote a trigger on lead which will fire when lead is converted and opportunity contact gets updated. trigger is working fine I need to create a test class for deployment
trigger updateopportunitycontact on Lead (before update) { for(Lead lead:System.Trigger.new) { if (lead.IsConverted) { Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId]; Opportunity opp = [SELECT Contact__c from Opportunity where opportunity.id = :lead.ConvertedOpportunityId]; opp.Contact__c = lead.ConvertedContactId; update opp; } } }
Below is the trigger which i wrote and i dont see any code coverage please suggest me how to make the changes.
@isTest(SeeAllData = true) private class auto_lead_assignment { public static testmethod void testautolead() { test.startTest(); Account A; A = [ select Id,Email_Domain__c,OwnerId,name from Account where BillingState = 'CA' and Email_Domain__c = 'walmartlabs.com' limit 1 ]; Lead l = new Lead(lastname='sudhir', company=a.name,Account__c = a.id,run_assn_rules_yn__c = true); insert l; Lead ld=[Select company from Lead where id = :l.Id]; update ld; test.stopTest(); } }
Thanks
Sudhir
All Answers
Thanks
Sudhir
Thanks for you reply its working perfect I have a confict with this class below class is giving me the error while deploying
System.DmlException: Update failed. First exception on row 0 with id 00Q180000028DDHEA2; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []
Class.ClassRunLeadAssignmentRules.assign: line 20, column 1
Please suggest me how to fix this issue
Thanks
Sudhir
Thanks
Sudhir
Thanks
Sudhir
I am getting apex exception from below class looks like some for the converted lead when they run the lead assignment from below class its taking to exception can you please suggest how to fix this issue.
Thanks
Sudhir