How to cancel Processes in a Process model with foreach when a list of number(process Ids) given as input?

How to loop through each process id in a list of process Ids, to cancel corresponding process inside a process model.

As shown in below image, used an expression rule inside a script task node, to get list of process Ids. 

how to loop through each item in the list and call "Cancel Process" node by passing each process id as input? Please advise.

 

with(
local!dataset: a!queryProcessAnalytics(
report: cons!NSA_AllProcesses_Report,
contextProcessModels: cons!NSA_AllPMsForReport_Cons
),

local!requiredColumnConfig: reject(fn!isnull, a!forEach(
items: local!dataSet.columnConfigs,
expression:if(index(fv!item, "label", {}) = "ProcessId", index(fv!item, "field", ""),null)
)),

local!filterColumnConfig: reject(fn!isnull, a!forEach(
items: local!dataSet.columnConfigs,

expression:if(index(fv!item, "label", {}) = "NSARequestId", index(fv!item, "field", ""),null)
)),

index(a!queryProcessAnalytics(
report: cons!NSA_AllProcesses_Report,
contextProcessModels: cons!NSA_AllPMsForReport_Cons,
query: a!query(
filter: a!queryFilter(field: local!filterColumnConfig, operator: "=", value: ri!NSARequestId), pagingInfo: a!pagingInfo(1,-1))
).data, tostring(local!requiredColumnConfig), {})

)

 

  Discussion posts and replies are publicly visible