You need to sign in to do that
Don't have an account?
Shawn Reichner
Case Trigger Not Firing
Hello,
I have created a class and trigger which I will paste below. These are on the case object and in sandbox at the moment until I can get them to operate correctly.
What I want to happen is when a certain picklist choice is chosen, I woudl like the trigger to automatically populate another field with a certain value.
Here is my code currently, can anyone please help with figuring out why this is not updating the field when that picklist value is chosen and the case record is saved?
Thank you,
Class
public class salespersonextraction {
public static void salesextract(List<Case> Cases){
for (Case c:Cases){
IF (c.AVI_SPL_Rep_Whse_Office_Code_2011__c == 'AB_Calgary_780S_780600_CAD'){
c.Salesperson_Extraction_Code__c = '780S';
IF (c.AVI_SPL_Rep_Whse_Office_Code_2011__c == 'AL_Birmingham_120S_120600_AVI'){
c.Salesperson_Extraction_Code__c = '120S';
}}}
}}
Trigger
trigger Salesextract on Case (before insert, before update) {
List<Case> Cases = Trigger.new;
salespersonextraction.salesextract(Cases);
}
I have created a class and trigger which I will paste below. These are on the case object and in sandbox at the moment until I can get them to operate correctly.
What I want to happen is when a certain picklist choice is chosen, I woudl like the trigger to automatically populate another field with a certain value.
Here is my code currently, can anyone please help with figuring out why this is not updating the field when that picklist value is chosen and the case record is saved?
Thank you,
Class
public class salespersonextraction {
public static void salesextract(List<Case> Cases){
for (Case c:Cases){
IF (c.AVI_SPL_Rep_Whse_Office_Code_2011__c == 'AB_Calgary_780S_780600_CAD'){
c.Salesperson_Extraction_Code__c = '780S';
IF (c.AVI_SPL_Rep_Whse_Office_Code_2011__c == 'AL_Birmingham_120S_120600_AVI'){
c.Salesperson_Extraction_Code__c = '120S';
}}}
}}
Trigger
trigger Salesextract on Case (before insert, before update) {
List<Case> Cases = Trigger.new;
salespersonextraction.salesextract(Cases);
}
First, let me congradulate you on the use of a class for your trigger logic.
use: System.debug('Some message here'); through out your code so you can see what, if anything is firiing.
but I think there's some syntax issues with the code: Try this
Note the ending } after the c.Salesperson_Extraction_Code__c = '780S'; and it's sister if clause.
ps: the little < > symbol on the formatting bar will help you format your code in a nice, easy to read manner.
All Answers
First, let me congradulate you on the use of a class for your trigger logic.
use: System.debug('Some message here'); through out your code so you can see what, if anything is firiing.
but I think there's some syntax issues with the code: Try this
Note the ending } after the c.Salesperson_Extraction_Code__c = '780S'; and it's sister if clause.
ps: the little < > symbol on the formatting bar will help you format your code in a nice, easy to read manner.
Thanks again,
Shawn