03-05-2024 10:58 AM
I am working on a new pipeline for syncing some data. as part of that sync I want to compare my new data against the data in the target system so I don't update any data that is unchanged. in order to do this I have written an expression to do a lookup on some types in the system to ensure that I'm only comparing things of the same type (ex legal names with legal names).
I've written the following expression:
jsonPath($, "persons.old[*].names[*].type.detail.id").indexOf(jsonPath($, "valcodes['person-name-types'][*]").filter((value)=>value.code=='LEGAL')[0].id) != -1 ?jsonPath($, "persons.new.names[0].firstName") != jsonPath($, "persons.old[*].names[jsonPath($, "persons.old[*].names[*].type.detail.id").indexOf(jsonPath($, "valcodes['person-name-types'][*]").filter((value)=>value.code=='LEGAL')[0].id)].firstName"): false
which is supposed to get the index of the proper name in the document and then if it finds the type exists in the list it's supposed to check if the old name of that type is different from the new name of that type. Where I'm struggling is with the index check, the expression
jsonPath($, "persons.old[*].names[*].type.detail.id").indexOf(jsonPath($, "valcodes['person-name-types'][*]").filter((value)=>value.code=='LEGAL')[0].id)
when run alone returns an index for me generally a 0 or 1, which I was hoping to use to get the proper name item in the list, but when I attempt to add the lookup in place of the * in names[*] I get the error:
03-05-2024 12:03 PM
Since I didn't add it before, this is an example of an expression that works, but it has the key I need hard coded I just need to find a way to dynamically get that key from my valcode table instead of having to hard code it
jsonPath($, "persons.old[*].names[*].type.detail.id").indexOf(jsonPath($, "valcodes['person-name-types'][*]").filter((value)=>value.code=='LEGAL')[0].id) != -1 ?jsonPath($, "persons.new.names[0].firstName") != jsonPath($, "persons.old[*].names[?(value.type.detail.id == '55110e25-2ec5-421f-82d5-cc98451a019e')].firstName").toString(): false
03-06-2024 03:18 AM