You need to sign in to do that
Don't have an account?
Francisco Riccomagno 1
Change the picklist type depending on a record type
Hello, I'm totaly new to the salesforce development world, so maybe this is not the correct question to make.
I'm doing a quick app to try to understand how to develop on salesforce and I came to a moment where I don't know what to do. I need 2 different user to be able to choose a value from a picklist. The thing is that one user should be able to choose more than one value, an the other only one.
I tried to solve this by creating 2 different profiles, and try to create a record type, but the problem is that with the record type I can limit the values shown in the picklist, but can't change from a "Only one" selection to a Muptiple selection.
Maybe my way of thinking the solution is wrong, but is there a way of doing this? If not, how should be my way of thinking the solution to this?
Thank you in advance.
I'm doing a quick app to try to understand how to develop on salesforce and I came to a moment where I don't know what to do. I need 2 different user to be able to choose a value from a picklist. The thing is that one user should be able to choose more than one value, an the other only one.
I tried to solve this by creating 2 different profiles, and try to create a record type, but the problem is that with the record type I can limit the values shown in the picklist, but can't change from a "Only one" selection to a Muptiple selection.
Maybe my way of thinking the solution is wrong, but is there a way of doing this? If not, how should be my way of thinking the solution to this?
Thank you in advance.
I really can't think of a good way to do what you're looking for without creating a custom validation in apex.
If you're up for that, the values in a multi-select picklist are stored as a semi-colon separated string so it's a simple matter of splitting the value of the field on the semi-colons and counting the elements in the resulting array. If the rules are specific to the user rather than the records, it's probably better to base your validation on the user's profile or role rather than the record types.
Here's an example of a custom validation you could use for this. Call this method from a before insert or before update trigger to enforce your business rules.
Hope that helps. :)
All Answers
I really can't think of a good way to do what you're looking for without creating a custom validation in apex.
If you're up for that, the values in a multi-select picklist are stored as a semi-colon separated string so it's a simple matter of splitting the value of the field on the semi-colons and counting the elements in the resulting array. If the rules are specific to the user rather than the records, it's probably better to base your validation on the user's profile or role rather than the record types.
Here's an example of a custom validation you could use for this. Call this method from a before insert or before update trigger to enforce your business rules.
Hope that helps. :)
http://writeforce.blogspot.com/2012/11/the-trouble-with-picklists-visualforce.html