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
priya123priya123 

Want to display the default value in the standard picklist

I am displaying the task related fields and values in the visualforcepage.In this page, i just try to display the field as {!task.WhatId} in tag.But in the VF page, it is displaying the first value as default. I want to display the default value as Campaign.and also I am using the custom controller.Can anyone help?Very Urgent..
Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

You can achieve this by using the JavaScript on your page

 

For reference use the below code:

 

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

 

<apex:page controller="createtask" id="page1" >
<apex:form id="frm1" >
<apex:inputField value="{!task1.whatid}" id="taskwhatid"/>

</apex:form>
<script>
document.getElementById("page1:frm1:taskwhatid_mlktp").value='701';
</script>
</apex:page>

 

---- Apex Controller ----------------

 

public class createtask
{
public task task1{get;set;}
public createtask ()
{
task1=new task();
}
}

 

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

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

You can achieve this by using the JavaScript on your page

 

For reference use the below code:

 

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

 

<apex:page controller="createtask" id="page1" >
<apex:form id="frm1" >
<apex:inputField value="{!task1.whatid}" id="taskwhatid"/>

</apex:form>
<script>
document.getElementById("page1:frm1:taskwhatid_mlktp").value='701';
</script>
</apex:page>

 

---- Apex Controller ----------------

 

public class createtask
{
public task task1{get;set;}
public createtask ()
{
task1=new task();
}
}

 

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

This was selected as the best answer
priya123priya123
Thanks, It's working fine now..