function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ram ChaturvediRam Chaturvedi 

I am getting a error at the calling time of apex class by using costom java script button .?

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")}

var r = confirm(" Are you sure to call the apex class ?");
if(r == true)
{

sforce.apex.execute("javasclass","check",{str:'Amit'});
alert("Sent it for class");
}

---------------------------------------------------
global class javasclass {

    webservice static void check(string x){
       
        system.debug('this is x '+x);
    }
}

-----------------------------------------------
It gives a error :

  User-added image
Bhushan.AdhikariBhushan.Adhikari
Hi Ram,

You should use variable name 'x' not str. Try changing sforce.apex.execute("javasclass","check",{str:'Amit'}); to sforce.apex.execute("javasclass","check",{x:'Amit'}); this should work.

Regards,
Bhushan 
Ram ChaturvediRam Chaturvedi
Thanks Bhushan