10

I have an existing JavaScript button that calls Apex, and it works fine. I then want to add a second parameter to the method, but for some reason it isn't working. Is there something else I need to do?

The code below works:

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

var response = sforce.apex.execute("IFE/IFE_ButtonMethods", "createIQuoteCall", {oppID:"{!Opportunity.Id}"});

The Apex method that goes with it:

webservice static string createIQuoteCall(String oppID)
{

This following does not work:

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

var response = sforce.apex.execute("IFE/IFE_ButtonMethods", "createIQuoteAcc", {oppID:"{!Opportunity.Id}"}, {accId:"{!Opportunity.AccountId}"}); 

The Apex method that goes with it:

webservice static string createIQuoteAcc(String oppID, String accId)
{

The error I get is:

onSuccess not defined in the callback.

What am I doing wrong?

2
  • Can you up the verison to 30.0 for both the scripts and try? And also apex.execute call is a synchronous callout not sure why you're getting the callback error..
    – Sam
    Commented Mar 23, 2015 at 14:43
  • @theGreatDanton I just did it and got the same error. I have no idea. It doesn't make sense to me... that the first one works but not the second.
    – dphil
    Commented Mar 23, 2015 at 14:45

1 Answer 1

9

Your syntax is wrong. You should collect all parameters within one {...} block:

sforce.apex.execute("IFE/IFE_ButtonMethods", 
                    "createIQuoteAcc",  
                    {oppID:"{!Opportunity.Id}", accId:"{!Opportunity.AccountId}"});
4
  • I was about to answer this, you beat me to it :)
    – Sam
    Commented Mar 23, 2015 at 14:48
  • Gah I can't believe I didn't think of trying it like that. Thanks!
    – dphil
    Commented Mar 23, 2015 at 14:49
  • @theGreatDanton Hehe :) Next time then! Commented Mar 23, 2015 at 14:49
  • @dphil It was my first syntax error too, as I've started with ajax toolkit. Commented Mar 23, 2015 at 14:50

You must log in to answer this question.

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