2

So I have a VF page looking into a custom setting field - SetupOwner. The issue I'm having is I want to display only users and have end user only edit/add users to the custom settings as opposed to other objects (i.e. profile). See screenshot

enter image description here

Here is the page and extension I've been working with:

-------------- VF page -----------------------

        <apex:pageBlocktable value="{!UserQueueSettings}" var="ES" id="memberTable" rows="1000" >


            <apex:column headerValue="Name">
                <apex:inputField value="{!ES.SetupOwnerId}"/>
            </apex:column>      

-------------- Extension -----------------------

public List<UserQueueSettings__c> getUserQueueSettings()
{
    settings = [Select SetupOwnerId,Priority_1__c,Priority_2__c,Priority_3__c From UserQueueSettings__c where SetupOwner.Username != null];
    return settings;
}    
1
  • 1
    I think the easiest way would be to use javascript / jquery to default all the dropdowns to the value User and then make them read only. – Aayush K Jan 14 '15 at 20:19
1

It appears you have created a Hierarchal custom setting. This allows settings to be made at the org-wide, profile, and user levels; SetupOwnerId is the field that identifies what user/profile the record applies to. By using <apex:inputField> with this field, VF is automatically generating the UI to select both profiles and users.

If you did intend to create a hierarchal custom setting but with to limit data entry to users only (no profiles), you probably want to avoid using <apex:inputField>. Perhaps a two-step wizard interface, where a user first selects the new record user; you then insert a new custom setting record for that user and then display the UI, using <apex:outputField> for SetupOwnerId and inputFields for the other fields.

0

I would suggest you use a dummy object that has a writeable lookup to User. For example if you had My_Object__c in your org with a User__c lookup, you could do something like:

public with sharing class MyController
{
    public List<Wrapper> wrappers { get; private set; }
    public MyController()
    {
        // initialize wrappers, etc.
    }

    public PageReference save()
    {
        List<My_Setting__c> settings = new List<My_Setting__c>();
        for (Wrapper wrapper : wrappers) settings.add(wrapper.getSetting());
        update settings;
        // return whatever;
    }
    public class Wrapper
    {
        final My_Setting__c setting;
        public My_Object__c dummy { get; private set; }
        public Wrapper(My_Setting__c customSettingRecord)
        {
            setting = customSettingRecord;
            this.dummy = new My_Object__c(User__c=setting.SetupOwnerId);
        }
        My_Setting__c getSetting()
        {
            setting.SetupOwnerId = dummy.User__c;
            return setting;
        }
    }
}

Then you could use the wrapper lookup in your markup:

<apex:inputField value="{!wrapper.dummy.User__c}" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.