Rule for creating list of CDTs based on input list of CDTs

I'm trying to populate one list of CDTs base on another input list of CDTs. My process has a step in which it stores records in WORKLOG table and retrieves primary keys of those records using process variable which is array of worklog CDTs.

I would like to use this pv!worklog as input into script task which will prepare another array of CDTs called pv!relation which then will be saved to database.

It looks like I need expression rule which will user pv!worklog and pv!employeeId as inputs and create array of relation CDTs by the rule "for each worklog entry create relation with input employee Id which is always single integer".

That array of relation CDTs should be saved into process variable pv!relation.

My attempt looks like this:

1) rule inputs:

2) rule code:

a!localVariables(
  local!worklog: ri!worklog
),
a!forEach(
  items: local!worklog,
  expression: append(
    ri!relation,
    'type!{urn:com:mcom:eedm}EEDM_Relation'(
      "EMPLOYEE",
      ri!employeeId,
      "WORKLOG ENTRY",
      fv!item.id,
      "WORK DONE"
    )
  )
)

My test input would be:

worklog entries:

{{1,"2020-01-01","Testing",3},{2,"2020-02-01","Testing",5}}

employeeId: 

3

Also, please give me advice how to map this rule input ri!relation (array of CDTs) to process variable outside of script task which will use this rule I'm trying to make work.

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data