首页 > 解决方案 > 在字典中查找关联值

问题描述

我有一个条件,我需要获取任务代码为“LIFE_MAX_DAYS”的字典的 taskId 值。我能怎么做 ?

Dictionary    
replFlag: null (Text)
    taskCode: "LIFE_MAX_DAYS"
    createdBy: "Administrator"
    createdOn: 3/20/2020 1:54 AM EDT
    lastModifiedBy: "Administrator"
    lastModifiedOn: 3/20/2020 1:54 AM EDT
    actionId: null (Number (Integer))
    priorityId: 5
    statusId: null (Number (Integer))
    concatKey: null (Text)
    taskId: 5980
    batchId: null (Number (Integer))
    id: 4
Dictionary
    replFlag: null (Text)
    taskCode: "LIFE_MAX_DAYS"
    createdBy: "Administrator"
    createdOn: 3/20/2020 1:54 AM EDT
    lastModifiedBy: "Administrator"
    lastModifiedOn: 3/20/2020 1:54 AM EDT
    actionId: null (Number (Integer))
    priorityId: 5
    statusId: null (Number (Integer))
    concatKey: null (Text)
    taskId: 5980
    batchId: null (Number (Integer))
    id: 5

标签: appian

解决方案


  • wherecontains查找提供数组值的索引。
  • 此外,列表支持多索引(例如{"a", "b", "c", "d"}[{1, 3}]返回{"a", "c"})。
  • 最后列出支持预计索引(例如{{x: 1}, {x: 2}, {x: 3}}.x返回{1, 2, 3}

这三个功能允许您执行此操作:

with(
  /* Pull out just the task codes of all the tasks */
  taskCodesOfTasks: listOfTasks.taskCode,
  /* Get the indicies where the task code is what we're looking for */
  indicies: wherecontains("LIFE_MAX_DAYS", taskCodesOfTasks),
  /* Pull out the task data */
  selectedTasks: listOfTasks[indicies],
  /* Return the task IDs */
  selectedTasks.taskId
)

当然可以用更少的仪式来拼写:

listOfTasks[wherecontains("LIFE_MAX_DAYS", listOfTasks.taskCode)].taskId

推荐阅读