2

I am getting this error. I know this question has been asked earlier too, i was wonderting if we can write any cutsom message in error.csv when those error out.

Also, is it salesforce bug or my code bug as it is throwing ..

Apex script unhandled trigger exception by user

to my email id

try{
        List<Database.Saveresult> accountupdatedResults =  Database.update(updateAccMap.values(), true);
        }
        catch(Exception e){


        }
3

This can happen if you are trying to share records with an inactive user or when you are assigning inactive user as the record owner .Make sure that you filter your query to include only active users with isActive=true .Certainly this is an error in apex and not an SFDC bug

For custom exception implement an exception class like below

public class InactiveUserException extends Exception {}

And then in your catch block use the below

try{
    update updateAccMap.values();
}catch(Exception e){
  throw new InactiveUserException(
           'Activated the user you are trying to assign the Account');
}
  • Thanks Mohith..Could you please guide me further as i dont have control over user active or inactive..i have to assigned them to account owner,can i do something so that atleast in error.csv it will write that user should be active while i was using Database.update(updateAccMap.values(), true);...do i have to put something in try catch so that it would not throw my exception on email – David Mycka Jun 26 '16 at 18:38
  • Yes if you can share the code ,I can help you – Mohith Shrivastava Jun 26 '16 at 18:39
  • i am only updating account fields from some other object..and at last i am using..List<Database.Saveresult> accountupdatedResults = Database.update(updateAccMap.values(), true);.....here is accountmap i have assigned some owners which are inactive and its throwing error – David Mycka Jun 26 '16 at 18:40
  • You can use try and catch and inside catch throw exception .You will create an exception class to write your own exception .Also please see how to click on edit of your question and attach code snippets with code editor – Mohith Shrivastava Jun 26 '16 at 18:44
  • Thanks Mohith..I was not aware that we can attached code later too once question has been asked..i will check it – David Mycka Jun 26 '16 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.