{!API.Session_ID} , sforce.connection.sessionId and skuid.utils.userInfo.sessionId

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Should there be any difference between {!API.Session_ID}, skuid.utils.userInfo.sessionId and sforce.connection.sessionId? 

I am calling conga merge composer and keep getting the SFDC login page during the composing process.  The conga process does work in the end - but after I login again.  

My code:

var partnerServer = sforce.connection.partnerServerUrls[8];

var hcURL1 = 'https://www.appextremes.com/apps/Conga/Composer.aspx'+         '?sessionId='+sforce.connection.sessionId+
      '&serverUrl='+partnerServer+
      '&id='+model1[0].Id+
      '&CongaEmailTemplateId=a4Z500000004F01'+
      '&reportid=[office]00O50000003QupQ?pv0='+model1[0].Id+
      ',[spouse1]00O50000003QrN4?pv0='+model1[0].Id+
      ',[spouse2]00O50000003QrNE?pv0='+model1[0].Id+
      '&EmailToId='+model1[0].Id+
      '&EmailFromId='+model1[0].Adviser_Id__c+
      '&DV0=https://stuff.betterstfuff.com/?sf='+model1[0].Id+
      '&DS7=2&LG4=1&LG1=+My+Email+1';
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Both return the same Session Id (a Visualforce Session Id). I seem to recall that other users have had trouble in the past trying to launch Conga from Skuid with Conga's Report-driven document merge approach, as opposed to the Conga Queries document merge approach. The reason is that the Report-driven approach requires a "Salesforce" Session Id, as opposed to a Visualforce Session Id. Because Skuid runs in Visualforce, Skuid gets a Visualforce Session Id, which seems to work for Conga Queries / SOQL-query based merges. 

I searched the Community to try to find an example of someone succeeding with a Report-based Conga query launched from Skuid, but haven't found one yet.
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
Zach, thank you for the response.  Is there an API to call a SF button via Javascript? 

For this:
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Peter, will the button included on the Skuid Page? If so, you could give the Button a Unique Id and then trigger a click on it via JavaScript, e.g. via

skuid.$('#MyButton').click();
or 
skuid.$('#MyButton').trigger('click');

If you don't want the button to be included on the Skuid Page at all, then no, there's currently not a documented Skuid API for doing this, but we could potentially add that if it was a significant need.
Photo of Peter Herzog

Peter Herzog

  • 1,664 Points 1k badge 2x thumb
Thanks!  As an FYI here is how I solved this issue... feels pretty hacky but it works!

var partnerServerExternal = sforce.connection.partnerServerUrls[24];
var partnerServer = partnerServerExternal.replace("mycompany--skuid.na1.visual.force.com","mycompany.my.salesforce.com");
    
    var URL = 'https://www.appextremes.com/apps/conga/pm.aspx'+ 
        '?sessionId='+sforce.connection.sessionId+
        '&serverUrl='+partnerServer+...
(Edited)
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Interesting! So you used the same Session Id, you just used a Server URL on the *.salesforce.com Domain tree, rather than on the *.force.com tree, and it worked --- that is very helpful. Good to know.