You need to sign in to do that
Don't have an account?
Trigger - FIELD_CUSTOM_VALIDATION_EXCEPTION - Help
Hi,
I have created a trigger and tested on the sandbox and it works fine. I implemented it on the production last night and recieved the following errors this morning.
Apex script unhandled trigger exception by user/organization: 00520000000lct9/00D200000000Aq6 UpdateToAccSetupForm: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0220000005vt34AAA; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, This category is under construction. An email notofication will be sent when available.: [] Trigger.UpdateToAccSetupForm: line 21, column 2
I have no idea why I am getting these errors, I recieved around 4 of them, can somebody please shine a light on this for me because I thought I had mastered the trigger.
Thanks in advance.
Here is my code:
trigger UpdateToAccSetupForm on Account (after update) { //Map to store SAP number - Map key is AccountID Map<String, String> SetupFormMap = new Map<String, String>(); //Loop for each update for (Account acc : System.Trigger.new){ //If SAP Number is not Null if (acc.IF_SAP__c != null){ //Put SAP ID into map. SetupFormMap.put(acc.ID, acc.IF_SAP__c); } else{ } } //Create a list to put all records in that need updating. List<AccountSetupForm__c> recordsforupdates = new list<AccountSetupForm__c>(); //For each key that is in the map and has an AccountSetupForm for (AccountSetupForm__c aacc :[Select Id, AccountName__c, SAP_Number__c from AccountSetupForm__c where AccountName__c IN : SetupFormMap.keySet()] ){ //If the Map contains the AccountSetupForm Foreign Key if (SetupFormMap.containsKey(aacc.AccountName__c)){ //Take SAP Number from map and add to AccountSetupForm aacc.SAP_Number__c = SetupFormMap.get(aacc.AccountName__c); //Add updated AccountSetupForm record to list. recordsforupdates.add(aacc); } } //Update all AccountSetupForm records update recordsforupdates; }
Hi,
Don't suppose you have a custom validation against AccountSetupForm__c that checks a category? FIELD_CUSTOM_VALIDATION_EXCEPTIONs are thrown by custom validators.
'This category is under construction. An email notofication will be sent when available.' message also has a spelling mistake (notification) which makes me think theres been some human intervention...
R.
All Answers
Hi,
Don't suppose you have a custom validation against AccountSetupForm__c that checks a category? FIELD_CUSTOM_VALIDATION_EXCEPTIONs are thrown by custom validators.
'This category is under construction. An email notofication will be sent when available.' message also has a spelling mistake (notification) which makes me think theres been some human intervention...
R.
I only checked the Account Validation Rules, silly me.
Thanks for correcting my school boy error.
Matt
Matty,
Can you elobrate on the solution.Because i am having similar kind of errors.
I have 2 custom objects lets say i have custom OBJECt 1 and OBJECT2.I have a total amount on the OBJECt 1 basing on the status on the OBJECt 2 i have update the amount on the OBJECt 1 and i have the validation rule on the OBJECt 1 to check for the negative values.So i am getting similar kind of exception can you please shed some light on this.
Matty,
Can you elobrate on the solution.Because i am having similar kind of errors.
I have 2 custom objects lets say i have custom OBJECt 1 and OBJECT2.I have a total amount on the OBJECt 1 basing on the status on the OBJECt 2 i have update the amount on the OBJECt 1 and i have the validation rule on the OBJECt 1 to check for the negative values.So i am getting similar kind of exception can you please shed some light on this.