Search code examples
sequenceibm-bpmmulti-instance-deployment

IBM BPM 8.5 Multi-instance sequence flow by custom order


Have loan task (see example below) which is separating by multi-instance loop:

loans[
   [loanNo:1, dueDate: 2020-10-10],
   [loanNo:2, dueDate: 2020-05-05],
   [loanNo:3, dueDate: 2020-07-07]
]

How to make sequence loop to loop by custom order, not by index (0,1,2) but by dueDate so that first element will be closest date 2020-05-05, then 2020-07-07 and etc..


Solution

  • You will have to order your array by dueDate after to pass it to your multi-instance loop.

    You could insert in your process a script step before your multi-instance task that do this ordering:

    tw.local.orderedLoans = loans.sort(function(a, b) { 
      return a.dueDate.localeCompare(b.dueDate) 
    });
    

    And then pass the tw.local.orderedLoans to the task