You need to sign in to do that
Don't have an account?
sansha
Assign default value to an inputfield of type picklist
I have an inputfield of type picklist. The picklist has the following values:
Cancelled
Draft
Pending
Completed
OnHold
I need to select one of the values(e.g. Draft) as the default value whenever the new page is opened.
I tried marking Draft option as the default value in Picklist values. However it does not work.
Please suggest.
Hi,
I'm having the same issue but am using an extension controller.
Is there a simple way to do this ?
Could you please advise how ?
Thanks in advance
Help to promote this idea:
http://ideas.salesforce.com/article/show/10098623/Enable_VF_inputfield_component_to_render_a_picklist_with_default_value_selected
This "idea" is still "under consideration". Wow. This is clearly a bug.
hey sansha can you tell me how to load the page with some values in pick list?
i know that i have to write my code in constructor of that controller?
but please show me a demo so that everybody can understand.
this question is still unsolved in community.........
learn and contribute..
thanks in advance.....
plaese show a demo code so other newbies of salesforce can understand that how to load the page with some value of picklist...
any kind of help will be appriciated...
Hey Sansha,
Could you please share the code that you have written to set the default value of your picklist in the constructor?
Thanks..
Hi All,
I tried to set default value Dynamically but it is not working. Temporary i used to set default picklist value manually and its working fine.
But my objective is to set default value dynamically.
Below is my apex code
Schema.DescribeFieldResult F = Account.Industry.getDescribe();
List<Schema.PicklistEntry> picklist = F.getPicklistValues();
String defPickListVal = null;
for (Schema.PicklistEntry pv: picklist) {
System.debug('*******'+pv.getValue()+'??????????'+pv.isDefaultValue()); // here i can see pick list value but isDefault is returning all False
if (pv.isDefaultValue()) {
defPickListVal = pv.getValue();
}
}
system.debug('Def Pick Val : ' + defPickListVal);
Is there another way that we can set picklist value dynamically?
Thanks
R.K
there are two ways
1. you can add a pick list value as "Select a Option" to the pick list values. After add you make it as default by editing field.
2. Another Salesforce is always provoide you first pick list value as "Select" so no need to add extra because first value of Pick list is always Null.
I hope above answer will satisfy your requirement.
Rakesh
Thank you for your immediate reply...But actually i wanted is a picklist with values 'a','b','c','d' .But when load the page want to see 'x' instead of 'none'