Comparing Two Consecutive Subobjects
I’m trying to move job history records from one system into another using SnapLogic, and the actual data transformation is working great. However, a requirement has come up that I need to check that, in the case of workers who were terminated and later rehired, they can’t have any activity in between the termination and rehire. Sometimes the data gets dirty though, and they had things like job changes or compensation changes while a worker was technically terminated listed in the system.
I’ve built the extraction and grouped each set of data, but I can’t figure out how to compare the two consecutive elements so I can use it to route. So for instance:
{
“groupBy”: {
“Employee ID”: “21194”
},
“Employee”: [
{
“Employee ID”: “21194”,
“Effective Date”: “1/15/2009”,
“Action”: “Hire”
},
{
“Employee ID”: “21194”,
“Effective Date”: “10/29/2009”,
“Action”: “Termination”
},
{
“Employee ID”: “21194”,
“Effective Date”: “10/29/2010”,
“Action”: “Rehire”
},
{
“Employee ID”: “21194”,
“Effective Date”: “09/14/1994”,
“Action”: “Compensation Change”
},
]
}
I want to find the node where the action is “Termiation”, then look at the next node and see if the action is “Rehire”, or if there is no other node after “Termination” If so, that is a valid record. If not, that needs to go to a different queue for error reporting.
I’ve tried every way I can think of, and am still stuck. Can anyone help?