0

how to get fields which are queryable(can be used in query) or filterable(property from schema) from an object like account without using soql queries. Any suggestions? how to achieve this.

1 Answer 1

1

If you want this done via apex, then use DescribeSObjectResult & DescribeFieldResult classes. These classes have method like isQueryable(), isFilterable(), isCreateable() and many more. Sample code snippets are already provided in the apex developer guide here & here.

You can also use SOAP api. Check out DescribeSObjectResult & DescribeGlobalResult.


Note that fields in Salesforce objects do not have a queryable attribute. This attribute is available at object level only and all the fields returned by describe object are queryable. That being said, you may run into issues using fields in a query's WHERE clause and that could be because of various reasons like lack of indexing. This usage of fields in WHERE clause is indicated by the field's filterable attribute.


If you simply want to view this in an UI tool, you can login to Workbench to get this information. Go to info > Standard & Custom objects > Select object under Choose an object to describe > Expand Attributes to view object level attributes or Fields to view the field attributes. Screenshot below for ref.

enter image description here


You may want to explore another popular tool Salesforce Inspector available in chrome web store. Post installation, this tool is visible as utility icon on your browser page and quite easy to use.

You must log in to answer this question.