2

I have status field with picklist values draft,send to Rep,Return to Manager,Complete.I want to show only one picklist value (Return To Manager)for one profile (Rep profile) when user is on Send To Rep status.I don't want to show other values(Draft ,Complete) for User with Rep Profile .How to achieve this on visualforce

I know this can't be done without record types . Any other approach

Currently I am displaying picklist field in visualforce page with apex:inputField tag

2
  • I don't think I understand. The picklist looks to have 4 values. When that value is already set to 'send to rep', you want to limit the select options available tio just 'Return to Manager'? Other than that all 4 select options would be available? Am I understanding the use case correctly? Commented Dec 5, 2013 at 14:46
  • yes I want to limit the picklist values to just 'Return to Manager' for Rep profile
    – sfdc
    Commented Dec 5, 2013 at 15:03

1 Answer 1

2

Im assuming your controller property to get the options looks something like one of the following

If you are taking the values directly from a specific picklist field

public List<SelectOption> getMyOptions() {

        List<SelectOption> options = new List<SelectOption>(); 
        Schema.DescribeFieldResult field = yuopurObject.YourField.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues()){
            options.add(new SelectOption(f.getLabel(), f.getLabel())); 
        }     
        return options;     
}

Or if you are manually adding the options, then something like this

public List<SelectOption> getMyOptions() {

        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('Option1','Option1'));
        options.add(new SelectOption('Option2','Option2'));
        options.add(new SelectOption('Option3','Option3'));
        return options;     
}

If you want to adjust the options according to profile then you could simply do something like this

public List<SelectOption> getMyOptions() {

      List<SelectOption> options = new List<SelectOption>(); 

      //Might want to look into storing in a custom setting to avoid SOQL call
      Profile p = [Select Id, Name From Profile Where Name = 'Your Profile Name'];
      if(System.Userinfo.getProfileId() = p.Id){
           //add your values here
      }else{
           //add alternate values here
      }

      return options;       
}
1
  • Thanks @sfdc_ninja.Currently I am displaying picklist in visualforce page with apex:inputfield.
    – sfdc
    Commented Dec 5, 2013 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .