将派生字段动态添加到通用数据类型的 Appian 方法?

The Appian way to add a derived field to a common data type on the fly?

假设我有一个 Appian common data type (CDT) called myTask which contains multiple fields taskName, taskQuarter, taskYear, taskId saved in a local variable (of an Interface) 如下所示

+ data (List of dictionary)
  + (Dictionary)
    - taskName:    "Plant trees." (Text)
    - taskQuarter: 1              (Number (Integer))
    - taskYear:    2020           (Number (Integer))
    - taskId:      0              (Number (Integer))
  + (Dictionary)
    - taskName:    "Cut leaves." (Text)
    - taskQuarter: 2              (Number (Integer))
    - taskYear:    2020           (Number (Integer))
    - taskId:      1              (Number (Integer))

在(接口的)本地范围内,我想为所有名为 taskLongName 的记录添加一个附加字段,这将是以下连接(伪代码):

taskLongName = taskName + " " + taskYear + " Q" + taskQuarter

请问我该怎么做?

事实证明这很简单:假设您定义了一个表达式规则 myGetAllTasks(),您可以将字典的初始列表放入 local!allTasks。接下来,我们使用Appian's a!forEach()函数:

a!localVariables(
local!allTasks: rule!myGetAllTasks().data, 
local!taskLongNames: 
  a!foreach(
    items: local!allTasks,
    expression: concat(
      fv!item.taskName, " for ",
      fv!item.processYear, " Q",
      fv!item.processQuarter
    )
  ),
  ... <-- Here comes the configuration (code) defining the actual interface
)