You need to sign in to do that
Don't have an account?
Query the values above or below specific value in a picklist
Is it possible to query a records based on a picklist value so that I query all objects above or below the specific picklist value. For example if I have pickilist Example__c in my custom object CustomObject__c
Example__c contains values contains values
Example1
Example2
Example3
Example4
Now I would like to make a SOQL query to fetch all the records who Example__c field set to value above 'Example3'. Is this possible? Could I use getPicklistValues() method to define which values are above the specific value? In other words does the getPicklistValues() return the values in the correct order?
Hi,
I don't think the answer is what you want. Yes, you can use getPicklistValues() method to define which values are above the specific value, and also this method can return the values in the correct order. So you can define your script something like this:
All Answers
The answer to the first part of your question is yes it is possible to query a records based on a picklist value by using includes keyword.
Select id, name from CustomObject__c where Example__c includes (Example3)
Also if you wish to exclude the value Example3 you can style your query as under:-
Select id, name from CustomObject__c where Example__c includes (Example1;Example2;Example4)
getPicklistValues() returns all the picklist values of a field of type picklist or multipicklist.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi,
I don't think the answer is what you want. Yes, you can use getPicklistValues() method to define which values are above the specific value, and also this method can return the values in the correct order. So you can define your script something like this: