function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OzymandiasOzymandias 

Multi-select picklist field doesn't show on profiles that don't have Create permission on object

I have a custom object with a multi-select picklist field and I'm trying to create a VF page that allows users to search for the custom object records using values of the multi-select picklist as criteria.

 

To do this, I've created a container object in the controller, and bind an <apex:inputField> to the container object's multi-select picklist field, so that the VF page displays the standard multi-select component. It works fine for me, but if a user with a profile that doesn't have Create permission on that object opens the page, the multi-select picklist field is blank. Is it possible to display the multi-select picklist field regardless of the user's object permission?

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

Unfortunately using inputField - you're stuck giving out Create permissions.

 

HOWEVER - what you CAN do, is to create an <apex:selectList multiselect=true> and manually / programmatically populate it with the values in the actual field.  When you're saving the record - you just pass the string array from it to your destination field.

 

-Andy

All Answers

Navatar_DbSupNavatar_DbSup

Hi,


Since you are binding the inputfield with multipiclist of your custom object user must have proper permission on that object. You can also check inside the field level security that this field is not hidden for that profile.

 

To check the field level security please go through this path:
Your name-> setup->Admin->SecurityControls-> Field Accessibility.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

OzymandiasOzymandias

Sorry, I forgot to mention that I already checked the field accessibility for the user's profile. It's editable on all of the object's record types. The user is able to edit and save changes to the field using the standard detail page of the custom object.

 

The profile just has Read and Edit permissions on the custom object though. I experimented with adding Create permission to the profile and confirmed that it makes the field visible on the VF page, which I find a bit weird. In any case, I won't be able to do that in production as it will break our internal business rules.

 

I guess my question is whether it's possible to override this in Visualforce, similar to what "without sharing" does to hierarchical sharing rules.

 

Andy BoettcherAndy Boettcher

Unfortunately using inputField - you're stuck giving out Create permissions.

 

HOWEVER - what you CAN do, is to create an <apex:selectList multiselect=true> and manually / programmatically populate it with the values in the actual field.  When you're saving the record - you just pass the string array from it to your destination field.

 

-Andy

This was selected as the best answer
OzymandiasOzymandias

Ok, got it. Too bad I couldn't simply use the inputField component, but thanks for clearing that up.

 

I did what you suggested, by dynamically generating a SelectOption List using the Schema object. I couldn't use <apex:selectList multiselect=true> though because the picklist has a lot of values and it wasn't user-friendly to scroll through the list and go ctrl+click on several selections. I ended up making a custom component that imitated the standard multipicklist component (patterned after this blog post) and it works fine now.