Hi i have written trigger in which SC_Problem_Management__c is parent object and SC_Problem_Case_Link__c is child object having master detail relationship. I want to update status field of parent object to awaiting deployment when all child records status having value as 'Tested'.
trigger updatestatus on SC_Problem_Case_Link__c(after update) {
List<SC_Problem_Management__c> parentObjList = new List<SC_Problem_Management__c>();
List<SC_Problem_Management__c> parentObjListToBeUpdated = new List<SC_Problem_Management__c>();
public List<Id> listIds = new List<Id>();
for (SC_Problem_Case_Link__c childObj : Trigger.new) {
listIds.add(childObj.SC_Problem_Management__c);
}
parentObjList = [SELECT Id,Status__c, (SELECT ID, Status__c FROM SC_Problem_Case_Link__r) FROM SC_Problem_Management__c WHERE ID IN :listIds];
Boolean checkApproval = TRUE;
for (SC_Problem_Management__c bid : parentObjList) {
for (SC_Problem_Case_Link__c bsaa : bid.SC_Problem_Case_Link__r) {
if (bsaa.Status__c == 'Tested') {
checkApproval = TRUE;
} else {
checkApproval = FALSE;
}
}
if (checkApproval == TRUE) {
bid.Status__c = 'Awaiting Deployment';
}
parentObjListToBeUpdated.add(bid);
}
if (parentObjListToBeUpdated.size() > 0) {
update parentObjListToBeUpdated;
}
}
I am getting error while saving the trigger. "Error Error: Compile Error: Status__c,(SELECT ID, Status__c FROM SC_Problem_Case_Link__r) FROM SC_Problem_Management__c ^ ERROR at Row:1:Column:48 Didn't understand relationship 'SC_Problem_Case_Link__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 9 column 21"
Please guide on this issue.
Child_Relationship_Name__r