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
Chris LitesChris Lites 

Get multiselect chosen values before database commit.

Hi,

I am running in to an issue that I was hoping to get some advice on. I am building a visualforce page that exposes some multiselect picklists on a custom object. I would like to be able to find what the currently selected values of those picklists are (the ones on the right in the "chosen" area) and do a soql query based on those values. I would like to be able to do this with the current page state prior to actually commiting those values to the database. in fact, I would ideally like to do the query and then reset the values so none are chosen and none get committed to the database.

I have tried accessing the field values using the following:

Schema.DescribeFieldResult fieldResult = Custom_Object__c.Picklist__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

and that gives me a list of all the possible picklist values and if they are default and if they are active, but the active means "if this item must be displayed in the drop-down list for the picklist field in the user interface" so that is not helpful. I need a "selected" attribute or something of that nature.

Anyway, if anyone has any good ideas on how to access this or another way to accomplish this it would be appreciated.

Thanks,

Chris


Best Answer chosen by Chris Lites
bob_buzzardbob_buzzard
When the user executes an action method (clicking a button, for example), a page postback will take place and the values they have chosen will be updated in the record that they are editing.  Unless you commit these changes to the database, they will just stay in memory and you can do what you like with them.  The chosen values will appear in the field that the inputfield element is bound to - they will be a semi-colon separated list.