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

System.DmlException
Hi,
trigger contactEndDate on Contract (after insert, after update) {
Contract contract = trigger.new[0];
list<Contact> contactList = new list<Contact>();
Date sDate = contract.EndDate;
Id accID = contract.AccountId;
if(accID != null) {
Contact[] con = [select SMA_End_Date__c,Name From Contact where AccountId = :accID];
if(con != null && con.size() > 0) {
for (Contact contact : con) {
contact.SMA_End_Date__c = sDate;
contactList.add(contact);
}
update contactList;
}
}
}
When i try to invoke the above trigger i am getting this error
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger contactEndDate caused an unexpected exception, contact your administrator: contactEndDate: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 003L0000002xSxCIAU; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, ContactObj: []: Trigger.contactEndDate: line 13, column 13
Can anyone please help me to resolve this problem?
Thanks and Regards
Hari G S
Hello,
Well you have written validation rule on contact object which create this error. So my suggetion is use before update because it excute first before custom validation.
Think this will help you.
All Answers
There must be some validation rule on contact causing this exception,
Check it and try to satisfy that condition before updating the contacts.
Hello,
Well you have written validation rule on contact object which create this error. So my suggetion is use before update because it excute first before custom validation.
Think this will help you.