Hi Guys i am updating globalvalueset from batch and sorted is true everytime but when i run the batch first time and if sorted checkbox is not checked then its getting checked. and when i run the batch again its getting unchecked though sorted is true. if i run again third time its getting checked again..

following code for updating.

//preparing json
string JSONPicklist = prepareGlobalPicklistJSON(listofPicklistValue, gPicklistLabel, gPicklistAPIName);
        //Store GlobalPicklistId's in custom setting. and change when code moved to new org
        ToolingAPICalloutUtility.updateGlobalPicklist(JSONPicklist, gPicklistId);

method to prepare json based in wrapper class :

 static string prepareGlobalPicklistJSON(map<string,string> listofPicklistValue, string gPicklistLabel, string gPicklistAPIName) {

    list<GlobalPicklistJSONWrapper.PicklistValue>  PicklistValueList = new list<GlobalPicklistJSONWrapper.PicklistValue>();
    for(string pVal:listofPicklistValue.keySet()) {
        PicklistValueList.add(new GlobalPicklistJSONWrapper.PicklistValue(false, listofPicklistValue.get(pVal), pVal)); 

    GlobalPicklistJSONWrapper.MetadataObj  metadataObj1 = new GlobalPicklistJSONWrapper.MetadataObj(PicklistValueList, gPicklistLabel);

    GlobalPicklistJSONWrapper.globalPicklist globalPicklistObj = new GlobalPicklistJSONWrapper.globalPicklist(metadataObj1, gPicklistAPIName);

    //string JSON_P = JSON.serialize(globalPicklistObj);
    string JSONPicklist = JSON.serialize(globalPicklistObj).replace('default_Z', 'default');
     system.debug('Debug JSONPicklist '+JSONPicklist);
    return JSONPicklist;


wrapper class i am using :

 public class MetadataObj {
    public List<PicklistValue> customValue;
    public string masterLabel;  //Global Picklist Label Name
    public boolean sorted;   //make picklist sorted always.

    public MetadataObj(List<PicklistValue> cValues, string mLabel) {
        customValue = cValues;
        masterLabel = mLabel;
        sorted = true;


as you can see in wrapper class i have always added sorted as true.

What am i doing wrong here?

Thank you in advance.

Your Answer

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

Browse other questions tagged or ask your own question.