Activity Forums Salesforce® Discussions Showing Null value in OwnerEmail

  • Showing Null value in OwnerEmail

    Posted by Parv Shekhar Singh on May 31, 2018 at 7:58 am

    for(Account acc : Trigger.New){

    system.debug(‘>>>>>>>>’+acc.Owner.Email);

    }

    In my Trigger ‘account.Owner.Email’ is showing null value,but we have an email of Owner, can anyone help me with this?

    Aman replied 6 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Aman

    Member
    May 31, 2018 at 8:00 am

    Hi Parv,

    ‘Trigger.New’  only return data to single hierarchy.That's why you are getting null value in your case.For this first find out OwnerId then find Email of that based on it.

    for(Account acc : Trigger.New){

    String id = acc.OwnerId;

    }
    String email = [Select id,Email from User where id =: id].email;

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos