Forum Discussion
endor_force
2 years agoNew Contributor III
Hi Rajesh,
You can probably achieve this in multiple ways.
I try to keep it rather clean, using standard snaps, and not nest too much js code in the mappers.
My sample is first sorting based on employee id and effective date, then it is grouping all records for an employee id in to one.
Then you can generate the order and the end date individually using javascript map functions and split the employee out again.
Order = Index +1
$employee.map((item, index) => ({...item, Order: index + 1}))
Valid to = If there is another record, fetch its effective date-1, else null.
$employee.map((item, index) => ({...item,
ValidTo:
index+1 == $employee.length ? null :
Date.parse($employee[index + 1].EffectiveDate)
.minusDays(1)
.toLocaleDateString({"format": "M/d/yyyy"})
}))