Unfortunately it is not possible to dynamically/programmatically define the options of a
multiple-choice data type, as these need to be defined (hardcoded) in either the DataModel or the view itself.
If you want to stick with
multiple-choice data types then you can dynamically change the displayValue of the pre-defined options in the view in the component itself. Like this.
<single-choice-dropdown bind="ticket.job_type" required="false" >
But as you can see, even in this example you cannot change the
key options, only the
display values. This pattern is typically used to implement translations for
multiple-choice data types. Please note you can also use this pattern to limit which options are visible to the user in the specific view component, in other words if your data type actually has 10 options but you just want the user to see the first 3, then you can hardcode those three options into the component using this pattern.
That said, the recommended route for creating completely dynamic/programmatic
multiple-choice options is to use
DB objects instead, typically temporary
LocalDB objects, but you can also just store it in the normal
DB. You basically create all the options you want to present to the user as DB objects and display them using any query bound view component (
object-list, etc.) You then allow the user to select one or more of those objects and store and keep track of the selection in the DB, allowing you to update the UI to give feedback to the user that shows what they have selected. You can accomplish this by changing the color of the objects based on “selection” status or show an icon (like a checkmark) based on the “selection” status.