JavaScript Remoting from Skuid page launched from custom OnClick JavaScript button/link

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Hi,

For this use case, I launch my Skuid page using the following JavaScript:
{!REQUIRESCRIPT("......")}
var url = '/apex/skuid__UI?page=AwesomeSkuidPage&id=' + '{!sobject.Id}'; 
window.location.href = url;
On the awesome Skuid page, I have a page title button that performs even more awesomeness. The button Runs Multiple Actions that executes a JavaScript snippet which uses JavaScript remoting to invoke a remote action.  Note that the remote action must be asynchronous.

I do not want to include an Apex VisualForce page in order to include the necessary JavaScript ala https://community.skuidify.com/skuid/topics/javascript-remoting-and-skuid.

Is this possible?  I am relegated to implementing a custom REST service?

Thanks in advance,
Irvin
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Irvin have you read this post:  https://community.skuidify.com/skuid/topics/calling_apex_function

I'm not sure I know all the options,  but from that post it looks like you may have at least one "non-webservice" option. 
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Read the post this morning.  I am going with Option 2 at the moment.  Just repackaged my RemoteAction into a HttpGet.  Not quite sure how to get the server instance, however.

 $.ajax({        
       type: "GET",
        url: "??????",   <-- how to get the server URL?
        beforeSend: function (xhr) {
            xhr.setRequestHeader('Authorization', "Bearer" + sforce.connection.sessionId); <-- is this correct?
            xhr.setRequestHeader('Accept', "application/json");
            xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
            xhr.setRequestHeader('Access-Control-Allow-Methods', 'GET');
        },
        success: function (data) {
            console.log(data);
            deferred.resolve();
        }
    });
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
For others that may run into a similar use case, please consult this tutorial page:


http://help.skuidify.com/m/page-assig...


This tutorial describes how to use the Visualforce component approach where you create your own Visualforce Page and use the Skuid.Page component. This has the benefit of injecting the proper JavaScript into the page so that JavaScript remoting works.
(Edited)