+ Start a Discussion

UserInfo.getSessionId() returns null on a time-based workflow trigger



I have a future callout from a time-based trigger. This callout in turn calls a Visualforce page.

On the trigger, UserInfo.getSessionId() returns null, hence the page does not get invoked; the Http callout hits the Salesforce.com login page. Please suggest a way to obtain the sessionid on a Apex trigger invoked by a Time based workflow?


What is the validity time for a SFDC sessionid?


Andi Giri



Federico LarsenFederico Larsen

Hi Andi,


I have the same problem.

Did you find a way to get sessionid?


Best regards


Thanks in advance for any help provided.


for async process sectionid whould be null.


see this link at sessionId sessionid


Returns the session ID for the current session.

For Apexcode that is executed asynchronously, such as@futuremethods, Batch Apex jobs, or scheduled Apexjobs,getSessionIdreturnsnull.

As a best practice, ensure that your code handles both cases – when a session ID is or is not available.