You need to sign in to do that
Don't have an account?
I have an app called "Chemical Equipment" and two custom objects customer and invoices. I want to write a trigger on customer object, when ever the customer status in the customer object is active a invoice should be generated. Here is the code:
public class Cus_Inv_Exmp1 {
public static void callMe(List<APEX_Customer__c> customers )
{
List<APEX_Invoice__c> InvoiceList=new List<APEX_Invoice__c>();
for(APEX_Customer__c objCust:customers)
{
if(objCust.APEX_Customer_Status__c=='Active')
{
APEX_Invoice__c objInvoice=new APEX_Invoice__c();
objInvoice.APEX_Status__c='Active';
objInvoice.APEX_Description__c='Recored created through trigger';
objInvoice.APEX_Customer__c=objCust.id;
InvoiceList.add(objInvoice);
}
}
Insert InvoiceList;//DML
}
}
Callout for Trigger :
trigger Cus_Inv_Exmp1 on APEX_Customer__c (after update)
{
Cus_Inv_Exmp1.callMe(Trigger.new);
}
public static void callMe(List<APEX_Customer__c> customers )
{
List<APEX_Invoice__c> InvoiceList=new List<APEX_Invoice__c>();
for(APEX_Customer__c objCust:customers)
{
if(objCust.APEX_Customer_Status__c=='Active')
{
APEX_Invoice__c objInvoice=new APEX_Invoice__c();
objInvoice.APEX_Status__c='Active';
objInvoice.APEX_Description__c='Recored created through trigger';
objInvoice.APEX_Customer__c=objCust.id;
InvoiceList.add(objInvoice);
}
}
Insert InvoiceList;//DML
}
}
Callout for Trigger :
trigger Cus_Inv_Exmp1 on APEX_Customer__c (after update)
{
Cus_Inv_Exmp1.callMe(Trigger.new);
}
Please check do you have the picklist value added on this field APEX_Status__c
All Answers
Please check do you have the picklist value added on this field APEX_Status__c
If you see in the error message it clearly says that the bad value for the picklist, which means either the picklist value is missing or a spelling mistake.
Happy to help!