You need to sign in to do that
Don't have an account?
Andreas Diehl
Apex Class and Trigger to Update Industry Title based on SIC Code
Based on the provided SIC code I want to update a field with the respective Industry Title. Since there are too many SIC Codes to work with formula fields (exceeding field limits) I am left with Apex.
I have list of SIC Codes and their corresponding Industry Title;
lets say
1 = Industry A
2 = Industry B
3 = Industry C
2 = Industry B
3 = Industry C
Can you help with an Apex Class that uses the SWITCH statement to update a text field 'Industry_Title__c' (Text) based on a given value in the field 'SIC_Code__c' (Integer).
And can you help with a Trigger that executes the above class on every field change of 'SIC_Code__c'.
Thanks guys!
Please try with below sample code. This works when the Account record's SIC_Code__c field value is changed. (Change the code according to your requirements).
Trigger code: Apex class code: Hope this helps! Please mark as best if it does.
Thanks
All Answers
Please try with below sample code. This works when the Account record's SIC_Code__c field value is changed. (Change the code according to your requirements).
Trigger code: Apex class code: Hope this helps! Please mark as best if it does.
Thanks
Hi Sarvani,
just tested the proposed code and it works exactly as I requested. Thanks a lot!
Am I correct that I have to have a related test class when I want to deploy that to production!? How would that look like?
Really appreciate the help here!
Correct if you are trying to deploy production you need test class. Please try below code as a test class.
Hope this helps!
Thanks