You need to sign in to do that
Don't have an account?
aklkk
please give ma solution because i am not able to cover the test class code
hi all , i am not able to write to cover code palease suppot me
trigger soluation on gole__c(before insert,before update){
set<string> SetAgentIds = new Set<string>();
Map<string,string> MapSalesAgentsWithNpn = new Map<string,String>();
for(gole__c sales:trigger.new){
if(sales.Writing_Agent_ID__c!=null){
SetAgentIds.add(sales.Writing_Agent_ID__c);
}
}
if(SetAgentIds.size()>0){
for(Agent__c SalsAgent:[select id,AWN__c,NPN__c from Agent__c where AWN__c IN:SetAgentIds]){
MapSalesAgentsWithNpn.put(SalsAgent.AWN__c,SalsAgent.NPN__c);
}
}
for(gole__c sales:trigger.new){
if(MapSalesAgentsWithNpn.containsKey(sales.Writing_Agent_ID__c)){
sales.Writing_Agent_NPN__c=MapSalesAgentsWithNpn.get(sales.Writing_Agent_ID__c);
}
}
}
trigger soluation on gole__c(before insert,before update){
set<string> SetAgentIds = new Set<string>();
Map<string,string> MapSalesAgentsWithNpn = new Map<string,String>();
for(gole__c sales:trigger.new){
if(sales.Writing_Agent_ID__c!=null){
SetAgentIds.add(sales.Writing_Agent_ID__c);
}
}
if(SetAgentIds.size()>0){
for(Agent__c SalsAgent:[select id,AWN__c,NPN__c from Agent__c where AWN__c IN:SetAgentIds]){
MapSalesAgentsWithNpn.put(SalsAgent.AWN__c,SalsAgent.NPN__c);
}
}
for(gole__c sales:trigger.new){
if(MapSalesAgentsWithNpn.containsKey(sales.Writing_Agent_ID__c)){
sales.Writing_Agent_NPN__c=MapSalesAgentsWithNpn.get(sales.Writing_Agent_ID__c);
}
}
}
For a trigger, minimum 1% code coverage is required which can be attained easily by writing a simple test case.
Please check the below code, it will be useful: Above I filled only name fields, you can fill your fields accordingly.
You can also refer to https://trailhead.salesforce.com/en/content/learn/modules/apex_testing/apex_testing_triggers .
Hope my answer helps, select it as a best answer if it does.
Shubham Nandwana.
AppPerfect Corp.
salesforce@appperfect.com
408-252-4100
http://www.appperfect.com/services/salesforce/
Salesforce Development & Operations Experts