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

Parents
  • 0
    Certified Lead Developer

    Hi anushas0002 if i understood your question correctly, you have retrieved list of processId's and stored into a process variable (Multiple) and want to cancel either specific instance or all the process instances.

    if so, then there are various ways to achieve this requirement.

    1. Design your process like a loop configured along with a Gateway as shown in attached image. Where during each iteration you can use the current index to get the Process Instance id from your process variable and pass it to the smart service node to cancel the instance. Please find the screenshot of the configuration below.

    NOTE: If you want only specific process instance to be cancelled then, have a gateway before the Cancel Process Smart Service and handle it accordingly.

    2. An another way of doing this could be by configuring MNI as suggested by the practitioner above.

     

    As a conclusion, i would prefer to go for the first approach as my preference.

    Hope this will help you.

  • Is there a way to get all process variables from process model or process instance?

Reply Children
No Data