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
Kota Uday 6Kota Uday 6 

auto update picklist value using custom link

Hi Every one,

i have VF page having Delete custom link, wheni press delete that particulor picklist shouid update to another piclist value,
Ex: if my picklist is "Open quote",it should update as "closed by rep".

Please help me.
KaranrajKaranraj
Kota - Add command link visulaforce tag in your visualforce in the action method call your custom controller method to perform update operation and rerender the page to view updated result

Visualforce
<apex:page controller="yourPagecontroller">
//Other page logic
<apex:commandlink action="{!updateValue}" value="Delete"  rerender="outPanel"/>
<apex:outputpanel id="outPanel">
<!-- Picklist value section -->
</apex:outputPanel>
</apex:page>
Apex controller
public class yourpagecontroller{
 public Account acc {get;set;}
 public pageReference updateValue(){
   //write your logic to update value
   acc.picklistValue__c = 'setvalue';
   update acc;
 }​
}


 
Ajay K DubediAjay K Dubedi
Hii Kota,
You can try the following code for updating the picklist value on the button click.
Following is the controller and the page.
----------Controller------------
public class custompicklistcls {

    public String Selectthecountry {get;set;}
    public String Selectthecity {get;set;}
    boolean boo;
    
    public custompicklistcls()
    {
    boo=false;
    }
    
    public list <SelectOption> getcountry()
    {
        list <SelectOption> opt= new list <SelectOption>();
        if(boo == false)
        {
        opt.add(new SelectOption ('','select'));
        opt.add(new SelectOption ('India','India'));
        opt.add(new SelectOption ('US','US'));
        opt.add(new SelectOption ('UK','UK'));
        }
        else
        {
        opt.add(new SelectOption ('','select'));
        opt.add(new SelectOption ('India','India'));
        }
        return opt;
    }
    
    public list <SelectOption> getCity()
    {
        list <SelectOption> opt= new list <SelectOption>();
        opt.add(new SelectOption ('','select'));
        opt.add(new SelectOption ('Kanpur','Kanpur'));
        opt.add(new SelectOption ('Noida','Noida'));
        opt.add(new SelectOption ('Ghaziabad','Ghaziabad'));
        return opt;
    }

    public void myDelete(){
            boo=true;    
    }
}
----------Page---------
<apex:page controller="custompicklistcls">
    <apex:form >
        <apex:pageBlock >
                <apex:pageblockButtons>
                    <apex:commandLink value="Delete" action="{!myDelete}"/>
                </apex:pageblockButtons>
            <apex:pageblockSection id="test">
                <apex:selectList value="{!selectthecountry}" label="Country" multiselect="false" size="1">
                    <apex:selectOptions value="{!country}" rendered="true"/>
                </apex:selectList>
            </apex:pageblockSection>
            <apex:pageblockSection >
                <apex:selectList value="{!selectthecity}" label="City" multiselect="false" size="1">
                    <apex:selectOptions value="{!City}" rendered="true"/>
                </apex:selectList>
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Thanks.