You need to sign in to do that
Don't have an account?
Urgent: How to Update the multiple Detail Object records from master Field??
Hi All,
I need to update the Multiple Detail Object Records based on the Master Record field update...
Master Object: RMG_Employee_Master__c
Master Field: Proposal_Status__c
Detail Object: Proposal__c
Detail Field: Status__c
Please Suggest..
trigger detailstatus1 on RMG_Employee_Master__c (after insert,after update)
{
List<Proposal__c> ac = new List<Proposal__c>();
Set<id> Ids = new Set<id>();
for (RMG_Employee_Master__c o : Trigger.new) {
Ids.add(o.Id);
}
Map<id, Proposal__c> owners = new Map<id, Proposal__c>([Select id,Status__c from Proposal__c Where Id in :Ids]);
for (RMG_Employee_Master__c o : Trigger.new)
{
if(o.Proposal_Status__c != 'Closed')
{
//Instantiate a new account and set it to the current opportunity parent.
Proposal__c pc = owners.get(o.Id);
pc.Status__c = 'Closed';
ac.add(pc);
}
}
update ac;
}
HI, SMaster....
Use Below Trigger Code......
Hopes This Will Fulfill Your Requirement..............
trigger detailstatus1 on RMG_Employee_Master__c (after insert,after update) {
List < Id > empmasterIds = new List < Id >();
List < Id > proposalIds = new List < Id >();
for(RMG_Employee_Master__c rem: Trigger.New) {
if(rem.Proposal_Status__c != 'Closed'){
List<Proposal__c> proObj = [select p.Id,p.Status__c,p.RMG_Employee_Code__c from Proposal__c p where p.RMG_Employee_Code__c =:rem.Id];
if(proObj.size() > 0){
for(Proposal__c pc: proObj ){
pc.Status__c = 'Closed';
update pc;
}
}
}
}
}