I have one custom object Backlog and I have one picklist field Full_Name_of_the_Specialist__c which is having manually inserted all the Names of the Specialist profile. Now when new employee come, I want to dinamically assign them all from this profile to the picklist field. How can I achieve this?
-
2There are a couple of options: (1) Use a VF page/controller or Lightning component to dynamically construct the picklist from querying the User object; (2) Write apex code to update the field's picklist via the metadata API– cropredyMay 3, 2019 at 14:21
-
As someone whos done both the suggestions from cropredy, this is a LOT of overhead & coding required. I'd really consider if its worth it, especially if the list changes infrequently. Maybe having documentation for the admins to follow which details the steps required when a new staff / specialist is hired would be easier for your org to implement.– battery.cordMay 3, 2019 at 15:08
-
Also, even for unrestricted picklists, I've found that you can't use values outside the picklist as report filters without getting an error message, meaning that even if you write a bunch of code to dynamically generate picklists you still need to modify the actual metadata which requires a package install & callouts to the metadata api.– battery.cordMay 3, 2019 at 15:10
1 Answer
I am assuming here that you have the field "Full_name..." on the Backlog object. Is that a correct assumption?
You could achieve what you want to programmatically as indeed has been suggested. However, what is your use case? Because to me it sounds like you may benefit equally or better from creating a lookup field for the specialists.
I don't know how you are currently saving specialists in your system? But you could either create them as contacts (with a separate record type) or even as a custom object (e.g. if you don't want to link to accounts every time). Then in "Backlog", you can create a lookup that looks for these. With some additional config, you can also make sure that only the specialists can be found (i.e. not other contacts).
Was this helpful?
-
Custom object is normally the way to go, yes. Also note that, even if you really really want a picklist, it could still be nice to save your Specialists in a custom object. That way you could provide CRUD on this object to specific users in your org so they can manage the Specialists themselves (and they don't have to bother your SF Admin).– alamoMay 3, 2019 at 15:24