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
ZeeShan AbbAsZeeShan AbbAs 

Add Options to PickList Dynamically in User Standard Page

Hey,

I made a pickList in User object and want to add data dynamically but I cannot do it via controller because it is a Standard Page and I dont have access to controller as per my knowledge..
Is there is any way to add options dynamically through another controller like we can get options through Schema

 

public List<SelectOption> getName()
    {
    List<SelectOption> options = new List<SelectOption>();
    Schema.DescribeFieldResult fieldResult = User.Organization__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple)
    {
    	options.add(new SelectOption(f.getLabel(), f.getValue()));
    }       
    return options;
}

 

 Is there is any way to put values to that schema...??
thanks 



Big VBig V

If you are using standard controller then you can create an extension class and do the picklist creation in it.

for example supposing your visual page is for contacts.

 

<apex:page standardcontroller="contact" extensions="myclass">

           

            <apex:selectList value="{!selectedvalue}" multiselect="false">
           <apex:selectOptions value="{!Name}"/>
           </apex:selectList><p/>

 

</apex:page>

 

 

Create a class which acts as an extension for this VF page.

 

Public class myclass

{

  public string selectedvalue{get;set;}                   // this stores the selected value.

 

 public myclass(ApexPages.StandardController controller) {

    }

public List<SelectOption> getName()
    {
    List<SelectOption> options = new List<SelectOption>();
    Schema.DescribeFieldResult fieldResult = User.Organization__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple)
    {
        options.add(new SelectOption(f.getLabel(), f.getValue()));
    }       
    return options;

}

}

 

 

if not working kindly let me know else if solved kindly mark it solved

Regards,

Big V

 

ZeeShan AbbAsZeeShan AbbAs

Thanks for your reply but there is a problem that I am using Standard Page so I think I cannot add Controller Extension to that page.. Am I..??

Big VBig V

I f you want this to be in statndard functionality of user object, it may not be possible as the record type options are not availaable in User object to change the pick list values according to our needs.

 

 

Regards,

Big V