Forum Discussion

kachanta's avatar
kachanta
New Contributor
3 years ago

Filter in the array

Hello Community,
I have been trying hard to build a logic urgently. I’m requesting SnapLogic expression language experts to assist here.

I have the input data like below and need to get the phone “number” filed validating 3 conditions.

  1. Type should be ‘Mobile’ in array “phone”
  2. type should be == ‘Voice’ inside the array “utilizationMeanings”
  3. endDate field should be null which is inside another array “dates” inside “utilizationMeanings”

To detail: $ phones[ < find type = Mobile >].utilizationMeanings[ < find type= voice >].dates[< find endDate ==null>].number

{
“phone”: [
{
“number”: “123456789”,
“type”: “Mobile”,
“utilizationMeanings”: [
{ “type”: “Voice”,
“dates”: [
{“startDate”: “2023-05-31T12:08:47.503Z”,“endDate”: null }
]
},
{
“type”: “Text”,
“dates”: [
{“startDate”: “2023-05-30T00:00:00”, “endDate”: null }
]
}
]
}
]
}

5 Replies

  • vincenr's avatar
    vincenr
    New Contributor III

    Quick question about the first two snaps in my pipeline (Oracle Execution and the mapper snap), if there is more than one row of results in the ‘Select’ query, how does snapLogic decide which value to assign to ‘AUDIT_COUNT’ in the mapper snap? Because my comparison in the ‘Is there data’ router looks to see what the value is… if it’s not zero, it executes the upper pipeline; if it’s zero, it executes the lower pipeline. So far it’s working, but I’m not sure if it’s because it just takes ‘AUDIT_COUNT’ from the first row of results, which will either be zero if the dummy record is the only row, or something other than zero if there are any other rows (ex: AUDIT_COUNT is 2 or 5 etc).

    • vincenr's avatar
      vincenr
      New Contributor III

      But will the $ = {} work if my router snap has a mapper snap and pipeline execution snap in between it and the Oracle Execute?

  • vincenr's avatar
    vincenr
    New Contributor III

    Ok, so I changed the pipeline to compare $ = {} but it’s not working for me.

  • vincenr's avatar
    vincenr
    New Contributor III

    Sorry, this is what I changed it to which would be the correct logic for my case:

  • vincenr's avatar
    vincenr
    New Contributor III

    But the main thing I’d like to know is how does snapLogic decide behind the scenes how to populate AUDIT_COUNT with the pipeline I pasted above? Does it use the count from the first row in the returned rows or what does it do?