โ04-29-2020 08:02 AM
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?
โ04-29-2020 09:34 AM
Hi, Iโm not a person knowledgeable enough to give you a solution, but I was curious when I read this. It looks like a logic problem. If after termination and thereโs a comp or job change action, wouldnโt it always get routed to error handling (since the dirty data would occur before a rehire action, according to how you described it)?
โ04-29-2020 10:37 AM
What happens is that people are scheduled to be rehired. Their compensation is updated. Then their rehire date changes, but that compensation update isnโt changed to match the rehire date. So you have some messy data laying around.
Now weโre moving to a new system, and that system wonโt allow the dirty data to be loaded. Thus I need to catch what is causing problems before we try and load anything.
โ04-29-2020 12:29 PM
Try this pipeline:
Community7373_2020_04_29 (1).slp (6.2 KB)
The crux is a Mapper with an expression like this:
match $.Employee.findIndex(e => e.Action == "Termination") {
i if i == -1 => "VALID",
i if i == $.Employee.length - 1 => "VALID",
i if $.Employee[i+1].Action == "Rehire" => "VALID",
_ => "INVALID"
}