You need to sign in to do that
Don't have an account?
wpatters
Field update trigger
Hello everybody, I'm pretty new with writing apex, and I'm trying to write a trigger which causes a checkbox to be checked or unchecked in my contacts object when a field is updated in another object (Legislature). I'm not sure what is going wrong with the code I've written, but I've got the sneaking suspicion that it is entierly too simple. I am trying to update all of the contacts from the state associated
with the Legislature object that got updated. Also, the
Presently_in_Session__c field is a formula field that returns "TRUE" or "FALSE"
depending on the current date, and is the field which will determine
the state of the Legislature_in_Session__c checkbox on the contact
object. Anyway, here it is:
I am not getting any errors, but it is not doing anything. Any help would be greatly appreciated.
Message Edited by wpatters on 09-12-2008 01:15 PM
Message Edited by wpatters on 09-12-2008 01:34 PM
Code:
trigger Session_Check on Legislature__c (before update) { List<Contact> updatedContacts = new List<Contact>(); for(Contact c : [SELECT id, Legislature_in_Session__c FROM contact WHERE Calculated_State_From_KeyPerson_Home_Bus__c = '{!Legislatures__c.State__c}']){ if('{!Legislature__c.Presently_In_Session__c}'=='TRUE'){ c.Legislature_in_Session__c = true; }else{ c.Legislature_in_Session__c = false; } updatedContacts.add(c); } update updatedContacts; }
I am not getting any errors, but it is not doing anything. Any help would be greatly appreciated.
Message Edited by wpatters on 09-12-2008 01:15 PM
Message Edited by wpatters on 09-12-2008 01:34 PM
Message Edited by wpatters on 09-12-2008 03:07 PM