+ Start a Discussion
TylerBrooksTylerBrooks 

How do I update a picklist value from a visualforce page?

I'm creating a visualforce page that displays data for confirmation when changes are made to a record and I wanted an email to be triggered when the changes are confirmed/ submitted. I added a picklist to the object and reference it in the page using

<td><apex:inputField value="{!RMA__c.Changes_have_been_review__c}"/>        
            </td>

It shows up fine and has the values from the picklist field but whenever you select your value and hit submit it doesn't update the objects field. 

Any help would be appreciated.

-Tyler
Best Answer chosen by TylerBrooks
karthikeyan perumalkarthikeyan perumal
  Hello, 

1.Using this Example Code save this code as VF page, 
 
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Update"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
2.  preview. can able to view this page. 
3. place ID value in URL as query string . then try to update Type picklist value. 

User-added image

Hope this will help you. 

Thanks
karthik

 

All Answers

karthikeyan perumalkarthikeyan perumal
  Hello, 

1.Using this Example Code save this code as VF page, 
 
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Update"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
2.  preview. can able to view this page. 
3. place ID value in URL as query string . then try to update Type picklist value. 

User-added image

Hope this will help you. 

Thanks
karthik

 
This was selected as the best answer
manoj nagireddy 3manoj nagireddy 3
Hi,
Tyler Brooks 14



<apex:page standardController="Account" >
    <apex:form>
        <apex:pageBlock title="PickList Update" mode="edit">
            <apex:pageBlockSection columns="1"  title="Account Edit">
                <apex:inputField value="{!Account.Changes_Have_Been_Review__c}"/>  // Changes Have Been Review is the custom picklist field //
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
                <apex:commandButton value="UpDate" action="{!Save}"/>                        
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image

hope this will help you.

Thanks,
Manoj.