I am using simple-salesforce to read metadata from some CustomObjects: metadata = _sf.mdapi.CustomObject.read(sf_object_name)
This generally works, EXCEPT for a number of Picklist fields: the options return as a named ValueSet instead of a list of options (see below).
How can I get the actual Picklist options? Do I need to call a different API method with the ValueSetName (ex. Student_Challenge_Experience_Homesick
)?
{
'fullName': 'Experiencing_Homesickness__c',
...
...
'type': 'Picklist',
'unique': None,
'valueSet': {
'controllingField': None,
'restricted': True,
'valueSetDefinition': None,
'valueSetName': 'Student_Challenge_Experience_Homesick',
'valueSettings': [
]
},
'visibleLines': None,
'writeRequiresMasterRead': None
},
For completeness' sake: some fields DO return a list of picklist values with their label & value:
'valueSet': {
'controllingField': None,
'restricted': None,
'valueSetDefinition': {
'sorted': False,
'value': [
{
'fullName': '3',
'color': None,
'default': False,
'description': None,
'isActive': None,
'label': '3'
},
{
'fullName': '4',
'color': None,
'default': False,
'description': None,
'isActive': None,
'label': '4'
},
{
'fullName': '5+',
'color': None,
'default': False,
'description': None,
'isActive': None,
'label': '5+'
}
]
},
'valueSetName': None,
'valueSettings': [
]
},
'visibleLines': None,
'writeRequiresMasterRead': None
},
Sounds like a global picklist (picklist definition that can be reused, even on different objects, maintained in 1 place and if you add a new value - it adds everywhere). https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_globalvalueset.htm
See if you can pull it with
_sf.mdapi.GlobalValueSet.read('Student_Challenge_Experience_Homesick')
Or alternative approach is to query the picklists: https://stackoverflow.com/a/76840387/313628