Expression help
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: