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

John DahlbergJohn Dahlberg Member, Sonar
edited December 2017 in Questions
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.

Comments

  • edited December 2017
    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'
            };
        }
    }

  • John DahlbergJohn Dahlberg Member, Sonar
    edited October 2017
    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
Sign In or Register to comment.