1

I have a method :

webservice static String myMethod(String objectType, String recordId, Map<String,String> fieldValueMap )

I need to pass this in onclick javascript custom button.

sforce.apex.execute("myClass","myMethod",{objectType:"payId",recordId:"recId",...});

But I am not finding a way to pass a way to pass map as a parameter. Can anyone help on above.

1

If you want a map like this:

Map<String, String> MyMap = new map<String, String> {
    'key1' => 'value1', 
    'key2' => 'value2'};

Then you must send an object containing a Property for each Map. Each Property will be named as the Key for the Map, and and the value of that Property will be the Value for the Map. The JavaScript object to send would look like:

var someObject = {};   
someObject['key1'] = 'value1';
someObject['key2'] = 'value2';
0

You can create wrapper/separate class class as

webservice static String myMethod(Parameters  parameter )


public class Parameters   {
public String objectType{get;set;}
public String recordId{get;set;}
public Map<String,String> fieldValueMap {get;set;}
}


sforce.apex.execute("myClass","myMethod",parameter 
 : {objectType:"payId",recordId:"recId",...});
  • no my question is how to pass Map<String,String> as parameter in key value format – wizard May 18 '17 at 11:39
  • you can pass e.g. fieldValueMap : {"FirstName":"Prakash", "LastName":"Nawale"} – Prakash Nawale May 18 '17 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.