You need to sign in to do that
Don't have an account?
Calling apex controller form javascript ?
Hi there,below is the code which calls my apex webservice conroller class and method,
when i execute below code I am getting "undefined", what is wrong with below code
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
try{
var enrollmentEventId='{!Enrol_Event__c.Id}'
alert("test before calling calsss="+ enrollmentEventId);
var result = sforce.apex.execute("CSFcallExternalECWS","invokeExternalWs",{enrollmentEventId:enrollmentEventId});
alert("result="+result);
alert("test after calling calsss="+ enrollmentEventId);
}
catch(err) {
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.description+result+ "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
global classCSFcallExternalECWS
{
public static string enrolmentEventId;
webservice static string invokeExternalWs(string enrolmentEventIdValue)
{
enrolmentEventId=enrolmentEventIdValue;
returnenrolmentEventId;
}
The only problem I could foresee is if this is a managed app, you must include the namespace of the package:
CSFcallExternalECWS should be namespace.CSFcallExternalECWS (where namespace is the namespace of the package).
Was just about to say the same thing. Check the Namespace prefix that should be used.
we don't have any namespace or any package, it is simple webservice apex class.
Did you check your Apex Class List to see, or are you just assuming? I only ask because we need to completely rule it out.
I also tried copy/pasting into my dev org, and had to add the Namespace prefix, and then it worked.
I got it, ya i forgot about namespace, I didn’t look properly.
Awesome! Can you mark sfdcfox's post as a solution and give both us some Kudos? ;-)