function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi jayanth,
Can you please provide me what data is coming in respBodyMap and valuesObjList
public static List<String> getPickListValuesByRecordTypeId(
string objectName,
string recordTypeId,
string fieldApiName
) {
Httprequest req = new HttpRequest();
req.setEndpoint(
URL.getSalesforceBaseUrl().toExternalForm() +
'/services/data/v50.0/ui-api/object-info/' +
objectName +
'/picklist-values/' +
recordTypeId +
'/' +
fieldApiName
);
req.setMethod('GET');
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
Http http = new Http();
HttpResponse res = http.send(req);
//ystem.debug('body11:' + res1.getBody());
Map<String, Object> respBodyMap = (Map<String, Object>) Json.deserializeUntyped(
res.getBody()
);
//system.debug(lst_JsonParse.get('values'));
List<object> valuesObjList = (List<object>) respBodyMap.get('values');
List<string> pickValues = new List<string>();
for (object obj : valuesObjList) {
Map<string, object> valuesMap = (map<string, object>) obj;
pickValues.add((string) valuesMap.get('value'));
}
system.debug('pvalues ' + pickValues);
return pickValues;
}
Hi jayanth,
Can you please provide me what data is coming in respBodyMap and valuesObjList
respBodyMap
{"controllerValues":{},"defaultValue":{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"New","validFor":[],"value":"New"},"eTag":"574d09f5a9c1e4a57ebd (12 more) ...","url":"/services/data/v50.0 (66 more) ...","values":[{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"New","validFor":[],"value":"New"},{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"Disqualified","validFor":[],"value":"Disqualified"},{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"Working","validFor":[],"value":"Working"},{"attributes":{"converted":true,"picklistAtrributesValueType":"LeadStatus"},"label":"Qualified","validFor":[],"value":"Qualified"}]}
valuesObjList
[{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"New","validFor":[],"value":"New"},{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"Disqualified","validFor":[],"value":"Disqualified"},{"attributes":{"converted":false,"picklistAtrributesValueType":"LeadStatus"},"label":"Working","validFor":[],"value":"Working"},{"attributes":{"converted":true,"picklistAtrributesValueType":"LeadStatus"},"label":"Qualified","validFor":[],"value":"Qualified"}]
Please feel free to play on the above code in Execute Anonymous and let me know if you have any concerns.
Thanks,
Jay
I am getting a 401 error when I use the solution above in an Aura app. Do you have a clue on what I should do to solve this?
Do you got the solution?. I'm also facing the same issue