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

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


1 Answer 1


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

    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 Commented Jun 26, 2016 at 18:38
  • Yes if you can share the code ,I can help you Commented Jun 26, 2016 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 Commented Jun 26, 2016 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 Commented Jun 26, 2016 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 Commented Jun 26, 2016 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .