I am scheduling a job in which i need to pass session Id. How can i get session id of user at that point.

system.schedule('Test process 10 past', '0 10 * * * ?', new TestSchedule(UserInfo.getSessionId()));

Any ideas?

  • Are you saying that UserInfo.getSessionId() does not work here? If it does not work, what error are you getting? – Jagular Sep 9 '14 at 14:41
  • Why do you want the user's session Id in the scheduled job? Won't it be invalid when the job runs? – Dominic Sep 9 '14 at 14:47
  • @Jagular It is giving error of invalid session Id. – Pankaj Sep 10 '14 at 6:49
  • @Dominic I need to pass the session Id as i have to pass it in authorization header of a web service. – Pankaj Sep 10 '14 at 6:50
  • @pankaj So the batch service makes a callout, and uses the SFDC Session Id to do it? Who is it calling? I'm intrigued about what you're doing. – Dominic Sep 10 '14 at 7:10

Your Answer

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

Browse other questions tagged or ask your own question.