Trying to add custom javascript button to SKUID

  • 1
  • Question
  • Updated 5 years ago
I am trying to add a custom Javascript Button to SKUID this is a working functional button.  Here is the button code:

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
sforce.apex.execute("SGSFA_NA_OverLay","OverlaySales", {id: '{!Opportunity.Id}'});
window.alert("Overlay Sales Team has been added" );
window.location.reload();

I have added the requirescripts as external resources in Skuid and taken them out of the code in the snippet that I am adding.  However, when I press the button I get the following error:

POST https://sungardas--ebuatb--skuid.cs11.visual.force.com/services/Soap/package/SGSFA_NA_OverLay 500 (Server Error) connection.js:595

Uncaught {faultcode:'sf:INVALID_SESSION_ID', faultstring:'INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session', }


Any ideas on how to get this working would be appreciated.  Thanks!


Photo of Jacob Gmerek

Jacob Gmerek

  • 110 Points 100 badge 2x thumb

Posted 5 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Jacob,  Skuid comes with connection.js included, so you just need to include apex.js.  I think removing connection.js may help you get past the invalid session error.  The next possible issue that I see is your opportunity merge.  I would start with a hard-coded opportunity id and make sure that works first.  Then you'll need to use skuid's javascript api to retrieve the correct opportunity id.  

var oppModel = skuid.model.getModel('OppModelName');
var oppRow = oppModel.getFirstRow();
var oppId = oppRow.Id;

Let me know if this makes sense, if not, maybe you can give us access to your org and we can troubleshoot.