You need to sign in to do that
Don't have an account?
![NIyathi NIyathi](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Hi, I am asalesforce admin trying to move a change set into prod. I am stuck with a trigger with 0 % coverage.
Hi All, I am a salesforce admin trying to move this trigger with 0 % code coverage into prod. I understand the code but not sure how to write a test class. Help !!!!!
trigger UpdateContactInfo on soship__c (before insert) {
soship__c[] shipments = Trigger.new;
Set<String> orderNumbers = new Set<String>();
Map<Id,sohdr__c> orders = null;
sohdr__c order = null;
for(soship__c ship : Trigger.new ){
orderNumbers.add(ship.soship_order__c);
System.debug('order number '+ship.soship_order__c);
}
orders = new Map<Id,sohdr__c>(
[Select Id, sohdr_order__c, sohdr_contact__c, sohdr_conemail__c,sohdr_conphone__c ,sohdr_conmethod__c
from sohdr__c where Id in :orderNumbers]);
for(soship__c shipment:shipments){
order = orders.get(shipment.soship_order__c);
if(order != null ) {
shipment.soship_contact__c = order.sohdr_contact__c;
shipment.soship_email__c = order.sohdr_conemail__c;
shipment.soship_phone__c = order.sohdr_conphone__c;
shipment.soship_conmethod__c = order.sohdr_conmethod__c;
}else
{
system.debug(' order is null' );
}
}
}
} }
}
trigger UpdateContactInfo on soship__c (before insert) {
soship__c[] shipments = Trigger.new;
Set<String> orderNumbers = new Set<String>();
Map<Id,sohdr__c> orders = null;
sohdr__c order = null;
for(soship__c ship : Trigger.new ){
orderNumbers.add(ship.soship_order__c);
System.debug('order number '+ship.soship_order__c);
}
orders = new Map<Id,sohdr__c>(
[Select Id, sohdr_order__c, sohdr_contact__c, sohdr_conemail__c,sohdr_conphone__c ,sohdr_conmethod__c
from sohdr__c where Id in :orderNumbers]);
for(soship__c shipment:shipments){
order = orders.get(shipment.soship_order__c);
if(order != null ) {
shipment.soship_contact__c = order.sohdr_contact__c;
shipment.soship_email__c = order.sohdr_conemail__c;
shipment.soship_phone__c = order.sohdr_conphone__c;
shipment.soship_conmethod__c = order.sohdr_conmethod__c;
}else
{
system.debug(' order is null' );
}
}
}
} }
}
I guess it's something like this:
You just need a class test thar execute a insert in the object.
Best regrets,
Marcilio