Activity Forums Salesforce® Discussions How to control the data of a Picklist in Salesforce? Reply To: How to control the data of a Picklist in Salesforce?

  • Subhendu

    January 5, 2018 at 12:08 pm

    Hi Rahul,

    As per my understanding, you are trying to have values in picklist depending upon the value in datetime field and you need to refresh it if the value in that field is changed. You can achieve this on a visualforce page. You will need to override standard buttons on Case Object to call that visualforce page.  The flow of the code will be somehow like-

    • Have an <apex:actionSupport> that will call the controller method to get picklist values on OnChange event of that datetime input field.
    • Pass the value of datetime field using <apex:param> to controller.
    • Calculate the values that you need to show in picklist based on the value entered in datetime field in the controller method and generate a list of the desired picklist values.
    • Assign the list of picklist values to a Property defined in the controller. Have that property called on that picklist field.

    In such way, the picklist values will populate on the fly while editing the record. You can either create a custom controller or you can set standard controller as Case on the page and implement this logic in page extension.

    Hope this gives you an idea of how you can achieve what you aspire.