AnsweredAssumed Answered

Compare dates/flags within child JSON nodes

Question asked by rwang on Jul 18, 2018
Latest reply on Jul 23, 2018 by trey.yeager826393

Hello community, 

 

I am facing a challenge to comparing data within a child JSON node. For example below, i want to only return one Address for a given Account by applying: (if status code <> A or Preferred Flag <> Y, then return nothing) 

  1. Status Code = A (active)
  2. AND Preferred Flag = Y (True) 
  3. AND most recent last modified date

This example only shows one document, imagine there are many similar JSON documents with different Account Id.  

 

I wonder if there is a way to do it without scripts? or if it has to be done by scripts, any suggestions on how to handle that? 

 

{
"AccountId" : "123",
"Address" : [
{
"StreetLine" : "113 Main Street",
"City" : "XZY",
"State" : "OO",
"ZipCode" : "11111",
"Country" : "United States",
"StatusCode" : "A",
"TypeCode" : "H",
"PreferredFlag" : "Y",
"LastModifiedDate" : "20121019 121233.000"
},
{
"StreetLine" : "456 Main Street",
"City" : "AAA",
"State" : "BB",
"ZipCode" : "22222",
"Country" : "United States",
"StatusCode" : "A",
"TypeCode" : "H",
"PreferredFlag" : "N",
"LastModifiedDate" : "20111019 222228.000"
},
{
"StreetLine" : "113 Main Street",
"City" : "CCC",
"State" : "DD",
"ZipCode" : "33333",
"Country" : "United States",
"StatusCode" : "A",
"TypeCode" : "H",
"PreferredFlag" : "Y",
"LastModifiedDate" : "20171019 12114.000"
}
]
}

Outcomes