Dynamic choice lists: Dynamic Choice and MultiChoice
Dynamic Choice
Dynamic Choice fields return either text or numbers corresponding to the IDs of records. However, it is not possible to directly access the selected records. To retrieve them, you can use the following method:
Accessing the Record:
Ninox
var selectedRecord := record('my Table', number('Dynamic Choice'));Dynamic Multi Choice (DMC)
For a Dynamic Multi Choice, you can retrieve an array of records based on the selected elements:
Retrieving Selected Records:
Ninox
var selectedRecords := for i in numbers('Dynamic Multi Choice') do
record('my Table', i);
end;Adding or Removing a Selection in a DMC
To programmatically add or remove a selection in a DMC, use numbers() to manage the selected values. For example:
Adding a Record to the Selection:
Ninox
var currentSelection := numbers('Dynamic Multi Choice');
currentSelection := array(currentSelection, [newRecordID]);
'Dynamic Multi Choice' := currentSelection;Removing a Record from the Selection:
Ninox
var currentSelection := numbers('Dynamic Multi Choice');
'Dynamic Multi Choice' := currentSelection[!= recordIDToRemove];These methods allow precise control over the records selected in a Dynamic Multi Choice field.
