动态选择与动态多选

动态选择

动态选择字段返回的是与记录 ID 对应的文本或数字。但无法直接访问所选的记录。要取回它们,可以采用以下方法:

访问记录:

var selectedRecord := record('my Table', number('Dynamic Choice'));

动态多选(DMC)

对于动态多选字段,您可以根据所选元素取回一个记录数组:

取回所选记录:

var selectedRecords := for i in numbers('Dynamic Multi Choice') do
  record('my Table', i);
end;

在 DMC 中添加或移除某项选择

要通过代码在 DMC 中添加或移除某项选择,请使用 numbers() 来管理所选的值。例如:

向选择中添加一条记录:

var currentSelection := numbers('Dynamic Multi Choice');
currentSelection := array(currentSelection, [newRecordID]);
'Dynamic Multi Choice' := currentSelection;

从选择中移除一条记录:

var currentSelection := numbers('Dynamic Multi Choice');
'Dynamic Multi Choice' := currentSelection[!= recordIDToRemove];

这些方法让您可以精确控制动态多选字段中所选的记录。