You need to sign in to do that
Don't have an account?
bhanu_prakash
Help me to write test class urgent
Hi,
Iam new to development, please help me to write test class ?
Thanks for advance
Iam new to development, please help me to write test class ?
trigger StandardContactRoleCreation on Contact_Role__c (before insert,before update) { List<OpportunityContactRole> oppConRoleList = new List<OpportunityContactRole>(); Id OldContactId = null; if(trigger.isInsert){ for(Contact_Role__c con: trigger.new){ OpportunityContactRole oppConRole = new OpportunityContactRole(); if(con.Contact__c !=Null) oppConRole.ContactId = con.Contact__c; if(con.Opportunity__c !=Null) oppConRole.OpportunityId = con.Opportunity__c; if(con.Primary__c !=Null) oppConRole.IsPrimary = con.Primary__c; if(con.Role__c !=Null) oppConRole.Role = con.Role__c; oppConRoleList.add(oppConRole); } } if(Trigger.isUpdate){ for(Contact_Role__c conRole: Trigger.new){ if(conRole.Contact__c != Trigger.oldMap.get(conRole.Id).Contact__c || conRole.Opportunity__c != Trigger.oldMap.get(conRole.Id).Opportunity__c || conRole.Primary__c != Trigger.oldMap.get(conRole.Id).Primary__c || conRole.Role__c != Trigger.oldMap.get(conRole.Id).Role__c){ OldContactId = Trigger.oldMap.get(conRole.Id).Contact__c ; } } if(OldContactId != Null){ OpportunityContactRole updateOppConRole = [Select ContactId,OpportunityId,IsPrimary,Role from OpportunityContactRole where ContactId =: OldContactId]; for(Contact_Role__c conRole1: Trigger.new){ updateOppConRole.ContactId = conRole1.Contact__c; updateOppConRole.OpportunityId = conRole1.Opportunity__c; updateOppConRole.IsPrimary = conRole1.Primary__c; updateOppConRole.Role = conRole1.Role__c; } oppConRoleList.add(updateOppConRole); } } upsert oppConRoleList; }
Thanks for advance
http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you
thanks