cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP IRPA array variable switch

ITUSER
Explorer
0 Likes
1,388

Hello,

I want to sort an array of dates in SAP IRPA, but I did not find a way to switch variables in my array when a date is prior to another one.

I tried using set variable value activity, but it is not possible to access my array at a certain index (array[index] "is not an alphanumeric value or underscore").

I also thought about using add value to list, but it adds at the end of the list and not at an expected index.

Finally, I tried a basic JS customed script, but it fails to assign values to my declared structure data type, as it is (supposedly) a constant value..

thanks for helping,

Théo

View Entire Topic

theohaastrup

In Custom script write the below code:

const dates = [{po: '81001', date: new Date('2021-06-28')},                                                                 
{po: '81005', date: new Date('2021-06-10')},
{po: '81002',date: new Date('2021-06-05')}];
const sortedDates = dates.sort((a, b) => a.date - b.date );
return sortedDates;
define output parameter sortedDates in custom script and loop it and display values using log message

 

now sortedDates will come in output

ITUSER
Explorer
0 Likes

Hello Sandeep, do you have an answer to my previous post ?