1

I wish to apply logic if a picklist field is a restricted picklist.

Let's say I have a restricted picklist field called 'County__c'.

I can see that there are a number of methods available in the Schema.DescribeFieldResult as per, but there isn't one for identifying if the picklist or multipicklist is restricted (has a value set) or not.

Schema.DescribeFieldResult describeFieldResult = Account.County__c.getDescribe();
system.debug('@@@ describeFieldResult  is: ' + describeFieldResult );

It seems I would have to go around the houses to achieve this functionality to query the sObject, record types of that sObject, running user, and then see what picklist values are available.

Is there any 'one liner' way to identify if a multi/picklist is restricted or not in Apex / SOQL?

7

The isRestrictedPicklist() method, documented at the link in your question, is what you're looking for.

  • Ouch - that's embarrassing. In my defense, when I did the execute anon, in the raw log, the isRestrictedPicklist doesn't appear. Thanks for your help! – Andy Hitchings Aug 1 at 12:44

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.