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…
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.skuid.com/t/calling-apex-function
Does that help?
Emily
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 = argumentsn0],
$ = 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);
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
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.