I am using schema.getGlobalDescribe()
to retrieve Object names and labels and further using the Object name to retrieve its field name, after that I'm converting the field names into a string (comma separated) but when I use it in a Dynamic Query, it throws an exception because it contains some fields that are not queryable. Is there a way to avoid such fields?
-
1can you please add what concrete exception are you facing? and code snipped with a query as well– Oleksandr BerehovskyiCommented Dec 19, 2023 at 8:41
Add a comment
|
1 Answer
You can try using the standard classes of Salesforce - DescribeFieldResult and DescribeSObjectResult
Schema.DescribeFieldResult f = Account.Industry.getDescribe();
system.debug(f.isAccessible());
This will tell you whether the field is Accessible to the current user or not.