I am trying to update the status field of all the related child (Recipe Sheet Items) for a given parent (Recipe Sheet) when the status is updated to 'Void' and I am trying to make this trigger handle bulk. I get this error when I try to save it.
"Error: Compile Error: Method does not exist or incorrect signature: [LIST].keySet() at line 5 column 20"
Can someone please help me write this code correctly?
trigger SyncStatus on Recipe_Sheet__c(after update) {
If(Trigger.isUpdate){
Set<ID> ids = Trigger.new.keySet();
list<Recipe_Sheet__c> updatedParents = [SELECT Id,
(SELECT Id, Recipe_Sheet__c, Status__c
from Recipe_Sheet_Items__r ) FROM Recipe_Sheet__c
WHERE Id in :ids];
List<Recipe_Sheet_Item__c> childrenToUpdate = new List<Recipe_Sheet_Item__c>();
//Then loop through each parent object in 'updated parent
for ( Recipe_Sheet__c p : updatedParents)
{
if(p.Status__c=='Void'){
//and loop thru each kid in the child set}
for(Recipe_Sheet_Item__c kid : p.Recipe_Sheet_Items__r)
{
///update logic from above
if( kid.Status__c != p.Status__c)
{
kid.Status__c = p.Status__c;
childrenToUpdate.add(kid);
}
}
}}
if( !childrenToUpdate.isEmpty)
{
update childrenToUpdate;
}
}}