[SalesForce] Javascript button calling Apex Class

I am trying to create a small prototype to basically construct a json message from a button call.

I have button code

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

var xx = "{!URLENCODE(Zuora__SubscriptionProductCharge__c.Id)}"
var json = sforce.apex.execute("SendConfig", "SendCharge"{ChargeId:"xx"})

alert(json);

and class

   global with sharing class SendConfig{


   webservice static string SendCharge(string ChargeId)

   {

    // 
    Zuora__SubscriptionProductCharge__c chrg = [Select Access_Token__c,CODE_Filter__c,IP_Restrictions__c from Zuora__SubscriptionProductCharge__c where Id =:ChargeId Limit 1] ;

   JSONGenerator gen = JSON.createGenerator(true);   

   gen.writeStartObject();     
   gen.writeStringField('Token ', chrg.Access_Token__c);
   gen.writeStringField('CFE Code',chrg.CODE_Filter__c);
   gen.writeStringField('IP Addresses',chrg.IP_Restrictions__c);
   gen.writeEndObject();   

   String jsonS = chrg.getAsString();

   System.debug('jsonMaterials'+jsonS);

    return(jsonS);

  }

  }

but I am getting an error that there is a missing ) after argument list, I saw some issues about this being encoding so I am even doing URLENCODE but I am not using URL so that cant be it. I dont see where the missing bracket should be

Best Answer

You are missing a comma, In this line

sforce.apex.execute("SendConfig", "SendCharge"{ChargeId:"xx"})

Add the comma here

sforce.apex.execute("SendConfig", "SendCharge",{ChargeId:"xx"});
Related Topic