Problem with sforce.apex.execute

Brayden SmithBrayden Smith ✭✭
edited December 2017 in Problems
I'm converting the following onclick javascript to a Skuid javascript snippet, and am getting an "Uncaught TypeError" at execute. Any ideas on how to resolve this?

Salesforce Button:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}  {!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var originalValue = this.value;
this.value = "Processing...";
var request = new Object();
request.Action = "view";
request.AttachmentId = "{!ATT_EXP__Attachment__c.Id }";
request.UserAgent = navigator.userAgent;
debugger;
var attachmentURL = sforce.apex.execute("ATT_EXP.AttachmentsController","GetViewSignature",{JSONrequest:JSON.stringify(request)});
this.value = originalValue;
window.open(attachmentURL);
Skuid Snippet:
var params = arguments[0],   $ = skuid.$;   models = skuid.model.map();  var attachmentId = models.Attachment_view.getFirstRow().Id;    var originalValue = this.value;      this.value = "Processing...";  var request = new Object();      request.Action = "view";      request.AttachmentId = attachmentId ;      request.UserAgent = navigator.userAgent;    var attachmentURL = sforce.apex.execute("ATT_EXP.AttachmentsController","GetViewSignature",{JSONrequest: JSON.stringify(request)});    this.value = originalValue;  window.open(attachmentURL);

Comments

  • edited March 2017
    Brayden,

    Where does 'navigator.userAgent' originate?  I don't see it defined in your script.

    Thanks,

    Bill
  • Brayden SmithBrayden Smith ✭✭
    edited July 2017
    Its defined by the browser. When I use console log to view the "request" variable, it appears correctly.
    image
  • edited March 2017
    Brayden,

    Do you have a reference on the Skuid page to the ajax resource?

    /soap/ajax/29.0/apex.js

    image

    Thanks,

    Bill
  • Brayden SmithBrayden Smith ✭✭
    edited July 2017
    That's what it was! Thanks for helping me resolve this.

    -Brayden
Sign In or Register to comment.