You need to sign in to do that
Don't have an account?
Mayank07
how to update parent object's picklist value based on child object's picklist value
I have a master-detail relationship between Service_Request__c(Parent) & Service_Line__c(Child). for each child record there are three records created (Line_Type__c :- Line A Type, Line B Type, Line C Type). there's a field Status__c in the child Object which corresponds to each of the three records created. how to access the relationship between Each Line type record with their status?. here i want to check if for every Line_Type__c the status__c is 'Completed' so that the Parent object's (Service_Request__c) Status can be updated to 'Closed'.
for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c ]){ if( sl.Status__c == 'Completed') { sl.Service_Request__r.Status__c = 'Closed'; }
Review below snippet.
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Vinay Kumar