Let's take an example, you are developing a visualforce page with custom controller, And you have to display the field as either input or output mode based on the FLS permission for the specific field at the profile level who is running the page.
Note:
1. Invoice_OrderNumber__c is the custom field on Opportunity Object.
2. If the profile does not have permission(Visible, ReadOnly), then query will return zero results.
3. PermissionsEdit field on FieldPermission object will return the Boolean value as below,
- Boolean hasEditInvoiceField = false;
- List<FieldPermissions> invoiceOrderNumberFLS = [SELECT SobjectType, Field, PermissionsRead, PermissionsEdit, Parent.ProfileId FROM FieldPermissions where SobjectType = 'Opportunity' and Field='Opportunity.Invoice_OrderNumber__c' AND Parent.ProfileId=:Userinfo.getProfileId()];
- if(!invoiceOrderNumberFLS.isEmpty()){
- hasEditInvoiceField = invoiceOrderNumberFLS[0].PermissionsEdit;
- System.debug('####'+hasEditInvoiceField);
- }
Note:
1. Invoice_OrderNumber__c is the custom field on Opportunity Object.
2. If the profile does not have permission(Visible, ReadOnly), then query will return zero results.
3. PermissionsEdit field on FieldPermission object will return the Boolean value as below,
- If field have Visible access alone for the specified field then it return TRUE.
- If field have Visible and Read only access for the specified field then it return FALSE.
Reference:
Nice blog and too informative. The points presents in the blog is so impressive. Update more blog like this. Really appreciating for doing the blog like this. Thanks for sharing. Keep on updating more information. Eagarly waiting for you updates.tech service.
ReplyDeleteSEO Web Design Company Chennai
very informative blog and useful article thank you for sharing with us , keep posting learn more aboutsalesforce training,salesforce online training
ReplyDeletethis is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.
ReplyDeletesalesforce training in chennai
This comment has been removed by the author.
ReplyDeleteI am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.
ReplyDeleteSalesforce Training in Chennai
German Classes in Chennai
Salesforce Course
Salesforce Developer Training
German Language Course in Chennai
German Courses in Chennai
With Bulk Object Field Creator (BOFC) App user can (Compare or Export or Update) field permissions for multiple objects and for multiple profiles within same Salesforce org in few clicks.
ReplyDeleteAwesome nice post...
ReplyDeleteinternship report on python
free internship in chennai for ece students
free internship for bca
internship for computer science engineering students in india
internships in hyderabad for cse students 2018
electrical companies in hyderabad for internship
internships in chennai for cse students 2019
internships for ece students
inplant training in tcs chennai
internship at chennai
good....nice
ReplyDeletecategory/advocate-resume
category/agriculture-forestry-fishing
category/android-developer-resume
category/assistant-professor-resume
category/chartered-accountant-resume
category/database-resume
category/design-engineer-resume
category/developer-resume
category/engineer-resume
category/entrepreneur-and-financial-services-resume