Schema information isn't available via query, however there is an API for it. Depending on what type of development you're doing:
They all work a bit differently so if you have specific questions about using one of them it might be best in a followup question.
You should be able to get the data by querying (Tooling API):
SELECT Metadata FROM CustomField WHERE TableEnumOrId = '<Table Name>' AND DeveloperName = '<FieldName>'
The valueSet
attribute of the Metadata
field will contain the name of the global picklist used, if any.
Example (40.0):
{
"size" : 1,
"totalSize" : 1,
"done" : true,
"queryLocator" : null,
"entityTypeName" : "CustomField",
"records" : [ {
"attributes" : {
"type" : "CustomField",
"url" : "/services/data/v40.0/tooling/sobjects/CustomField/00N500000041HS5EAM"
},
"Metadata" : {
... // excluded for brevity
"valueSet" : {
"controllingField" : null,
"restricted" : true,
"valueSetDefinition" : null,
"valueSetName" : "A",
"valueSettings" : null
},
"visibleLines" : null,
"writeRequiresMasterRead" : null
}
} ]
}
Note that this will be the "developer" name of the valueSet. So, for example, above, my value set is called "A".
Best Answer
My strategy here would simply be to describe a picklist field that implements the
Global Picklist
.