Is there a way to find out using SOQL the association of global value set picklist with custom field?

I have custom field (test__c) dataType as a picklist and I select Use global picklist value set

I need to know either Apex/SOQL/tooling api what global picklsit name I have selected

Here is the attached screen shot.

enter image description here


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".


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.