You need to sign in to do that
Don't have an account?

Trigger to change a field of related contact before delete
Hi All,
i have a trigger on account object which upon delete action sends notification of the related contacts of the account to an external system, Now i want a particular field called status__c in contact to be changed to value "inactive" once the trigger is fired. The status__c field update to "inactive" should only happen on delete action. Please help me achieve this in below trigger.
i have a trigger on account object which upon delete action sends notification of the related contacts of the account to an external system, Now i want a particular field called status__c in contact to be changed to value "inactive" once the trigger is fired. The status__c field update to "inactive" should only happen on delete action. Please help me achieve this in below trigger.
trigger Contactcallout2 on Account(after update, before delete) { List<Contact> ListContact = new List<Contact>(); Set<ID> acctIds = new set<ID>(); if(Trigger.IsBefore && Trigger.IsDelete){ for(Account acct : trigger.old) { acctIds.add(acct.Id); } } else{ for(Account acct : trigger.new) { if(Trigger.oldMap.get(acct.id).Name != acct.Name){ acctIds.add(acct.Id); } } } if(acctIds.size() > 0){ for(Contact con : [SELECT id,Email,FirstName,LastName,phone,Title__c,Account.Name,status__c, AccountId FROM Contact WHERE AccountId IN : acctIds AND RecordTypeid = '012D1676545BaFA']){ WebServiceCallout.sendNotification(con.Id,con.Email,con.FirstName,con.LastName,con.phone,con.Title__c,con.Account.Name,con.status__c); } } }
Please change your code with below one :
Thanks,
Abhishek
All Answers
Please change your code as mentioned below :
I have added the code in between "Added Newly by Abhishek : Start/End" tags.
Please modify your code as above and let me know if you have issue.
Thanks,
Abhishek
Hi Abishek,
Many Thanks for the quick help.. Im just getting this error in line 19
Error: Compile Error: unexpected token: 'Select' at line 19 column 26...
Thanks
Abraham
Please change your code with below one :
Thanks,
Abhishek
Thanks
Abraham