You can use the SECURITY_ENFORCED clause in your SOQL queries, including subqueries and cross-object relationships while writing Apex code to apply field-level security.
For example:
List<Account> accList = [SELECT Id, parent.Name, parent.Website FROM Account WITH SECURITY_ENFORCED];
If you find this answer helpful, please mark it as the best answer. Thank you.
To put field level security with sharing, you need to follow these steps: Go to Setup and navigate to the object that contains the field you want to restrict access to. Click on the "Fields" section and select the field you want to restrict access to. Scroll down to the "Field-Level Security" section and click on "Set Field-Level Security." Check the boxes for the profiles and permission sets that should have access to the field. Click "Save" to apply the changes. To put field level security without sharing, you can follow these steps: Go to Setup and navigate to the object that contains the field you want to restrict access to. Click on the "Fields" section and select the field you want to restrict access to. Scroll down to the "Field-Level Security" section and click on "Set Field-Level Security." Uncheck the "Visible" and "Editable" checkboxes for all profiles and permission sets. Click "Save" to apply the changes.
If you find this answer helpful,Please mark it as the best answer.
You can use the SECURITY_ENFORCED clause in your SOQL queries, including subqueries and cross-object relationships while writing Apex code to apply field-level security.
For example: If you find this answer helpful, please mark it as the best answer.
Thank you.
Go to Setup and navigate to the object that contains the field you want to restrict access to.
Click on the "Fields" section and select the field you want to restrict access to.
Scroll down to the "Field-Level Security" section and click on "Set Field-Level Security."
Check the boxes for the profiles and permission sets that should have access to the field.
Click "Save" to apply the changes.
To put field level security without sharing, you can follow these steps:
Go to Setup and navigate to the object that contains the field you want to restrict access to.
Click on the "Fields" section and select the field you want to restrict access to.
Scroll down to the "Field-Level Security" section and click on "Set Field-Level Security."
Uncheck the "Visible" and "Editable" checkboxes for all profiles and permission sets.
Click "Save" to apply the changes.
If you find this answer helpful,Please mark it as the best answer.