Child to parent updation using Master- Detail relationship. Not possible workflow, Only possible on Trigger.
Ex:-
---
trigger OpportunityStageUpdate on Opportunity (after update) {
//create list of Opportunity IDs
List < ID > oid = New List < ID > ();
//find Opportunity to add to list
for (Opportunity o: Trigger.new) {
if (o.StageName== 'Closed Lost') {
oid.add(o.ID);
}
}
List < ProfessionalServicesRequest__c> PSRUpdateList= [SELECT Id,Status__c from ProfessionalServicesRequest__c WHERE Opportunity__c in : oid];
for (ProfessionalServicesRequest__c objPSR: PSRUpdateList) {
objPSR.Status__c = 'Request Cancelled';
}
update PSRUpdateList;
}
No comments:
Post a Comment