Has anyone worked with the skuid.sfdc.api.makeRequest API?

  • 2
  • Question
  • Updated 1 year ago
  • Answered
It would be helpful to be able to leverage the SFDC REST services with this method, but there isn't good documentation on it.  If I could get an example or an explanation on the parameters it would be much appreciated.
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb

Posted 1 year ago

  • 2
Photo of hareesh achanta

hareesh achanta

  • 90 Points 75 badge 2x thumb
Hi John

you can use the below snippet in java script and make an ajax request and get the response. This worked for us. Happy to help from Allegis :)
JS inline:

(function(skuid) {    var $ = skuid.$;
    $(document.body).one('pageload', function() {
        var myModel = skuid.model.getModel('MyModelId');
        var myComponent = skuid.component.getById('MyComponentUniqueId');
    });

    try {

        var request = '{ ' +
            '"inputs" : [ ' +
            '{ "request" : "value1"}, ' +
            '{ "request" : "value2"} ' +
            '] ' +
            '}';
        console.log(request);

        $.ajax('/services/data/v33.0/actions/custom/apex/ActionsForSkuid', {
            data: request,
            type: 'POST',
            crossDomain: true,
            dataType: "json",
            beforeSend: function(xhr) {
                xhr.setRequestHeader('Authorization', 'Bearer ' + sforce.connection.sessionId);
                xhr.setRequestHeader('Content-Type', 'application/json');
            },
            success: function(response) {
                console.log([response[0].outputValues.output, response[1].outputValues.output]); // ['returnValue1', 'returnValue2']
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log([jqXHR, textStatus, errorThrown]);
            }
        });
    } catch (e) {
        console.log(e);
        alert(e);
    }

})(skuid);




//Apex Class starts here

public class ActionsForSkuid {
    @invocablemethod(label = 'Skuid Exposed API')
    public static List < String > invokeApexAction(List < String > request) {
        System.debug(request[0]); // value1
        System.debug(request[1]); // value2

        return new List < String > {
            'returnValue1',
            'returnValue2'
        };
    }
}
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
Hareesh - Always good to hear from friends at Allegis.  Pass along hellos to the rest of the team for me.  

This snippet is very helpful.  Thanks