You need to sign in to do that
Don't have an account?
faceroy123
Trigger not executing
trigger volumes on case (before Insert, before Update) { for(case x : Trigger.New){ if (x.region__c == 'South West'){ x.consignments_volumes__c = Volumes__c.getinstance('1. January 2012 SW').Id__c; if (x.region__c == 'North West'){ x.consignments_volumes__c = Volumes__c.getinstance('2. February 2012').Id__c; } }}}
Hi, relatively new to this so I appreciate any help!
Can anyone advise why this trigger does not work? it's referencing a custom setting.
If I remove the 'if' line, then it seems to work. Any ideas?
Thank you
all the System.debug does is prints the line. You need to activate debug logs, then get your trigger to run. Then you can look at the log of what happened and see what printed up there.
All Answers
You need not correctly place your braces:
Your second if statement is contained INSIDE of your first, and so the following line:
never gets executed because it is impossible for:
which is what your logic really states.
Thanks Damien,
I think I understand, I have moved one of the braces but this still does not work,
where am I going wrong?
Thanks for your help
but this still does not work
What exactly doesn't work?
Try throwing a debug in to find out what the value of your region is to make sure the values are what you are expecting:
Try lining up your code better so it is more readable please. (You don't have to line it up the same way I do, but keep each line correctly tabbed at least. It makes it easier for someone else to help you debug your issue.)
The lookup field 'consignments_volumes' does not populate.
However, this does work
When I add the 'if' criteria it doesn't update the field.
Thank you.
Did you try it with the System.debug in there? If so, what printed up? Does it meet the criteria of those if statements?
I'm not sure what to expect with System debug. It didn't work with that in there.
all the System.debug does is prints the line. You need to activate debug logs, then get your trigger to run. Then you can look at the log of what happened and see what printed up there.
Thank you,
I found that there are 2 region fields - region_2__c was what I was looking for! meh!!
Thanks again