You need to sign in to do that
Don't have an account?
Christopher Picking
Need help converting the code in a trigger to a class.
My Trigger is a follows. I know this should properly be done by calling a method in a class via the trigger and in order to move this to production I need to have this in a class and then create the test class. I'm ultra new at all of this and really appreciate any help that you can provide.
trigger UpdateNCMOwner on Non_Conforming_Material__c (before insert, before update) {
for(Non_Conforming_Material__c n : Trigger.new){
if(n.NCM_Stage__c == 'In Process'){
n.OwnerID = n.NCM_Supplier_Buyer_ID__c;
}
else if (n.NCM_Stage__c == 'Resolution'){
n.OwnerID = n.NCM_Created_By_ID__c;
}
}
}
trigger UpdateNCMOwner on Non_Conforming_Material__c (before insert, before update) {
for(Non_Conforming_Material__c n : Trigger.new){
if(n.NCM_Stage__c == 'In Process'){
n.OwnerID = n.NCM_Supplier_Buyer_ID__c;
}
else if (n.NCM_Stage__c == 'Resolution'){
n.OwnerID = n.NCM_Created_By_ID__c;
}
}
}
This is the code,
You may need to make minor modification to line #1 and #2. In case you have some mandatory fields in object Non_Conforming_Material__c, you have to put values for them as well. Example: if you have mandatory fields Material_Size__c and Material_UOM__c the code will be like this,
All Answers
http://www.sfdc99.com/2013/05/14/how-to-write-a-test-class/
This is the code,
You may need to make minor modification to line #1 and #2. In case you have some mandatory fields in object Non_Conforming_Material__c, you have to put values for them as well. Example: if you have mandatory fields Material_Size__c and Material_UOM__c the code will be like this,