0

I am creating a JavaScript button that calls an apex class that returns a message string. I would like to show that string in a alert box when I press the button. Is there a way to do that?

This is what I have so far in my javascript button:

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

try{ 

sforce.apex.execute("Ctrl_JS_CallInformaDB","setCall",{"nif":'{!Account.NIF__c}', 
"country":'{!Account.BillingAddress}'}); 
window.location.href="/{!Account.Id}"; 
function onControllerReturn( returnMessage ) { 
alert(returnMessage); 
} 

}catch(err){ 
var txt = "Error: "; 
txt+=err.description+" 11"; 
alert(txt); 
}

1 Answer 1

2

Your code should be something like :

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

   try { 
      var returnMessage = sforce.apex.execute("Ctrl_JS_CallInformaDB","setCall", 
        {"nif":'{!Account.NIF__c}', 
        "country":'{!Account.BillingAddress}'}); 
        alert(returnMessage); 
     }catch(e){ 
    alert('Exception'+e) 
    }
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .