Could you help me find the problem with my custom Trigger? In a nutshell, I would like a picklist field called “Housekeeping_Status__c” to be updated to ‘Clean’ when the Account Id on one object (Housekeeping__c), is the exact account Id on another object (Property_Rate__c). Each object is unrelated but both share the same parent Account. This trigger should run (after insert, after update).
I should also mention that I have a second Housekeeping__c trigger (“Before insert, before update”) which populates the Account__r.Id on the Housekeeping__c record. I have no problem with this trigger.
Here is the broken code:
trigger setToClean on Housekeeping__c (after insert, after update)
{
for (Housekeeping__c housekeeping : Trigger.new)
{
String houseaccount = housekeeping.Account__r.Id;
List<Property_Rate__c> findRates = [SELECT Id FROM Property_Rate__c WHERE Account__r.Id = :houseaccount];
for (Property_Rate__c currentRate : findRates)
{
currentRate.Housekeeping_Status__c = ‘Cleaned';
}
}
}
Housekeeping_Status__c
even you are trying to access it in the trigger. – highfive May 27 '15 at 4:10