You need to sign in to do that
Don't have an account?
Jaime Soo See
How can I get isAccessible() on Campaign.Parent field
When I try to perform the following line of code:
Schema.sObjectType.Campaign.fields.Parent.isAccessible();
I get the following error: "parent is not a field of Campaign". However, when I look at the standard object in my org, I can see that there is a standard field "Parent". Is there a way to check the CRUD/FLS on this Parent field?
HI Jaime,
Just using 'Parent' will not work. According to Salesforce object reference guide, it should be used as 'ParentId'. Below line of code will work fine,
Please mark as Best Answer if it helped you.
Thanks for your quick response. I understand that I can check the ParentId field for accessibility, but does that mean it includes proper checking for the Parent field? (Tough way to word the question I know)
Here's an example: Does your example of checking the ParentId field for isAccessible() cover what I'm doing in the above SOQL query? i.e. I don't need to actually check for accessibility on the Parent field and the ParentID field?
Thanks!
I`m not quite sure I understand your question. Are you doing this to check if user can access the Object fields? Also, keep in mind ' isAccessible() ' is a boolean response so it will either return True or False based upon user`s accessiblity of that object. For example, if user cannot access that object or field, it will return as False. See example below,
To check the field-level read permission of the contact's email field before querying for this field:
Thanks!
Yes, you're correct. Before making a query on a field of an object, Salesforce requires an isAccessible() check on those fields first to ensure that you have the proper access.
So, before making a SOQL query on a set of fields, we must first check the accessibility of those fields. So, I have a SOQL query that does this: I would need to check accessibility as you mentioned: However, the check on the Parent is what fails with the above error.
Any help on how to check the acceissbility of just the Parent field? Or is checking the ParentId the same as checking the Parent field too? I hope that makes more sense.
Just wanted to follow up in case you had more input, it would be greatly appreciated.
Thanks!