Is there a way to add more selections into a multi-select pick list using apex? If there is a code sample or a link to some documentation would help. Thanks.
Are you looking to add more elements to the picklist configuration? I.e. mimic what you would do in the admin page?
If so, I think you're out of luck. We've struggled with this on a number of projects and have yet to come up with anything approaching a solution. If not, can you explain a bit more.
Sorry - I'm still not quite understanding what you are trying to do.
Do you want to add more values so that when the multi-select picklist is displayed on a standard page (for example), or are you trying to poplate a multi-select picklist field programmatically?
Ok, so lets say I have an Object called "Obj" with a multi-select picklist field called "pick" and I want to populate "pick" with "MyObj.name" when a MyObj record is created. Is that possible.
Yes, you can do that.
E.g.
Salesforce will also allow you to specify values that aren't in the picklist configuration - they get stored but can't be reported/filtered on.
All Answers
Are you looking to add more elements to the picklist configuration? I.e. mimic what you would do in the admin page?
If so, I think you're out of luck. We've struggled with this on a number of projects and have yet to come up with anything approaching a solution. If not, can you explain a bit more.
I would like to add more values to the list of values in the pick list.
Sorry - I'm still not quite understanding what you are trying to do.
Do you want to add more values so that when the multi-select picklist is displayed on a standard page (for example), or are you trying to poplate a multi-select picklist field programmatically?
Sorry I'm really bad at explaining things. I want to populate a multi-select picklist field programmtically.
You can set the values into the field as text separated by the semicolon character.
e.g.
Ok, so lets say I have an Object called "Obj" with a multi-select picklist field called "pick" and I want to populate "pick" with "MyObj.name" when a MyObj record is created. Is that possible.
Yes, you can do that.
E.g.
Salesforce will also allow you to specify values that aren't in the picklist configuration - they get stored but can't be reported/filtered on.
Thanks for the help
This example doesn't work any more. You compile error now with 'Expression cannot be assigned'
Any have the current correct answer to this question.
This should still work, as its just assigning a value to a field.
Which line gives the error - the instantiation or the assignment of the field?