How t call a apex class from skuid on an event and pass some data to the class and getting back the

edited March 2, 2017 in Questions
Hi , 

  we are trying to call an apex class with some parameters on an event on skuid and need to get some response back from the class. For making it easier i am taking a smaple scenario

This is my class , i have to pass models field comName as argument and have to get data back to skuid page 

public class SkuidTest{
    public static TESTOBJ__c  createEmployee(String comName) {
     
      TESTOBJ__c tst=new TESTOBJ__c ();
      tst.Name='SKUIDTEST001';
      tst.Company_Name__c=comNamecomID;
      
      insert tst;
       
        return tst;
    }
}

  Is there any workaround to achieve this, i have went through few approaches but couldn't make it..

Comments

  • Emily DavisEmily Davis ✭✭✭✭
    edited March 2, 2017
    Hi, Rajasekhar,
    Are you having issues with calling the Apex class in general, or with getting a response back? Have you seen the "Run Custom Apex Action" action type from within Skuid's actions framework? If you annotate your Apex method with the @InvocableMethd annotation, you can then call it from Skuid. To do this, add a button to a page title or a global action to your table, set it to Action Type "Run Multiple Actions", go to Actions, and add an action of type "Run Custom Apex Action". You should then be able to find your invocable method and send in the parameters needed. You might have to reload the page builder to see the new invocable method. :)


    If that doesn't work for you, I would check out Zach's ideas from this post:
    https://community.skuidify.com/skuid/topics/calling_apex_function

    Does that help?
    Emily
  • edited February 1, 2016
    Thanks Emily, I will try this approach.I have tried calling the class by making it as webservice but the apex class have to make one more external callouts this leads to callout loop exception.So i am directly making calouts to external services. 

      I have couple of questions here can you help me on these.

    1. Does calling apex actions will be useful in the case if i want some data to be returned after apex execution

    2. How to update back the returned data in the model.

     I am doing like this , but this is not updating any data on the model

    var params = arguments[0],  
        $ = skuid.$;

    try {  
        console.log(arguments);
        var model = skuid.model.getModel('Application');
        var row = model.getFirstRow();
        var request = '{"VIN":"' + row.Number__c + '"}';
        console.log(request);
       // 
    sforce.connection.remoteFunction({
           url : "url",
           method: "GET",
           onSuccess : function(response) {
                  console.log(response);
                  alert("sucess" + response);
            var obj = JSON.parse(response);
            var make=obj.make;
            var model=obj.model;
            var year=obj.year;
            model.updateRow(row,'Make__c',make);        
              },
           onFailure : function(response) {
                  alert("Failed" + response);
              }
       });

    }
    catch(e) {  
        console.log(e);
        alert('exception'+e);
    }
           model.updateRow(row,'Make__c',make);
  • Emily DavisEmily Davis ✭✭✭✭
    edited December 21, 2016
    Raj,
    If I understand correctly, you are getting the JSON response back, and the issue is just with the model row not updating? Have you confirmed that the value for makeis being populated correctly? Have you determined whether the issue is with actually updating the model row or saving the model after the update?
    Emily
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!