Suppose you have an app that schedules Batchables to run. If you wanted to access say the user ID and their email inside a batchable, so specifically in the execute(), how exactly can this be done?

What our app is doing is performing callouts, BUT we need the user information when sending the HTTP request to our api from salesforce.

Any help is appreciated, thanks.


For this, you can use:


See the documentation here for a full list of static methods that may be useful to you in this context.

Note, this will get information for the user that scheduled the Job in the first place which may/may not be what you need.

If you needed the same details for say a record owner, you would need to access that from the User object (using the OwnerId field as a lookup to User) within the execute() method itself.

  • exactly, thats the issue were having, the user email is always set to noreply@salesforce.com. So how exactly can we get this OwnerId to perform the loopup? – 1337holiday Apr 12 '13 at 20:15
  • @1337holiday, what are you saying here - you want the 'from' email address to be something other than [name] sent by noreply@salesforce.com? What do you want it to be? (you might consider posting another question, your original post doesn't say that). – Phil Hawthorn Apr 12 '13 at 20:44
  • Ok I'm Going to do that, our team has been working on this issue for the past week and cant seem to get this solved, so if you can help us out that would be great, thanks! – 1337holiday Apr 12 '13 at 20:45

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.