Skip to main content
Nintex Community Menu Bar
Question

calling apex method from java script in Skuid

  • July 10, 2024
  • 4 replies
  • 20 views

Forum|alt.badge.img+6

in my model i have a 4 fields like VIN(vehicle Identification number), make, model,year. whenever i enter VIN number, i want to cal the apex method from javascript. for this how to cal the method from javascript. can any one give some sample code for javascrpt to cal Apex method when i enter VIN number

4 replies

Forum|alt.badge.img+6

In order to do this, first you need to have a global class and your method should be a webservice method:

global class TestClass {&nbsp; &nbsp; <br> webservice static void testMethod(String testParameter) {<br>&nbsp; &nbsp; &nbsp; &nbsp; ..Do your stuff..<br>&nbsp; &nbsp; }<br>}


and then, you could call your apex method via javascript;

sforce.apex.execute(&nbsp;<br>&nbsp; &nbsp; 'TestClass',<br>&nbsp; &nbsp; 'testMethod',<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; testParameter : 'VIN'<br>&nbsp; &nbsp; }<br>);


Forum|alt.badge.img+2

@Hasantha Liyanage Hi this is not firing the class , 

global class SkuidTest{
    webservice static ID createEmployee(String companyName) {
     
      Employment_Experience__c  emp=new Employment_Experience__c();
      emp.Name=‘SKUIDTEST001’;
      emp.Company_Name__c=companyName;
      
      insert emp;
      
      return emp.Id;

    }
}

alert(‘vin check’);var redult=sforce.apex.execute( 
    ‘SkuidTest’,
    ‘createEmployee’,
    {
        companyName : ‘VIN’
    }
    );
  alert(redult);
 
  Is there anything we are missing in the approach



Forum|alt.badge.img+6

Rajasekhar,

Please refer the link  to the post by Ant Belsham : Calling apex function will explain everything for you 🙂


Arne-Per
Forum|alt.badge.img+8
  • Rookie
  • July 10, 2024

raj- you need to have added external resource for ajax tookit