You need to sign in to do that
Don't have an account?
Trigger on case Object to populate the fields .
Populate the Web_State__c and Web_Country__c fields based on the information entered in State_Code__c field.
When a case is created with the State code as "br-ac" , then the Web State should be populated as "Acre" and Web Country as "Brazil" .
i am trying to write a trigger for the above funcionality , here is my code .
trigger UpdateStateCountry on Case (before insert) {
List<Case> caseList = new List<Case>();
for(Case cs : Trigger.New){
if(cs.State_Code__c == 'br-ac' && cs.Alpha_3_Code__c == 'bra'){
cs.Web_State__c = 'Acre';
cs.Web_Country__c = 'Brazil';
caseList.add(cs);
}
if(cs.State_Code__c == 'br-al' && cs.Alpha_3_Code__c == 'bra'){
cs.Web_State__c = 'Alagoas';
cs.Web_Country__c = 'Brazil';
caseList.add(cs);
}
else {
cs.Web_State__c = 'None Provided';
cs.Web_Country__c = 'None Provided';
}
update caseList;
}
}
Is this what you are trying to do? You dont need to specify any dml calls inside the before insert trigger unless you are updating records in another object.