1

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..

Arturas
  • 161
  • 9
  • Format the question and make it proper readable for all. – ankitkanojia Jan 11 '20 at 03:34
  • How to make sequence multi-instance loop to loop by custom order, not by index (0,1,2) but by dueDate so that array with closest date will be passed first? Is it better? – Arturas Jan 11 '20 at 12:43

1 Answers1

1

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

EduMelo
  • 455
  • 3
  • 15