I have two forms linked and I want that if a user enters e.g. a building ID or a person ID or a telephone number in the child form, it would display corresponding data in a note field from the parent form. In other words, if someone enters 12345 for the building ID and keeps everything else blank, the form would display the first record corresponding to that building ID. If they enter 1234567890 for the person ID and leave everything else blank, then the form would display the first record corresponding to that person ID which may or may not be the same information corresponding to the building ID.
My form currently looks like this
Unfortunately the record found does not seem to correspond to the data entered although it does pull something. And I was hoping to only show the National ID Number
To pull the data, I am using this if statement in a calculate field. I included some line breaks to hopefully make it more readable.
if((instance('dana')/root/data[locationgrp/BBID=current()/../../searchgrp/BBID][position()=1] and ${BBID}!='')
or (instance('dana')/root/data[_/occupant_info/National_Registration_Number=current()/../../searchgrp/National_Registration_Number][position()=1] and ${National_Registration_Number}!='')
or (instance('dana')/root/data[_/occupant_contact/contact_home=current()/../../searchgrp/contact_home][position()=1] and ${contact_home}!='')
or (instance('dana')/root/data[_/occupant_contact/contact_work=current()/../../searchgrp/contact_work][position()=1] and ${contact_work}!='')
or (instance('dana')/root/data[_/occupant_contact/contact_mobile=current()/../../searchgrp/contact_mobile][position()=1] and ${contact_mobile}!='')
,instance('dana')/root/data[_/occupant_info/National_Registration_Number][position()=1]
,'not found')
I am not at all sure if I on the right track or if I’m thinking about this the wrong way. I want to eventually extend or repeat this so that I can display all the data from the first row returned from the parent form.

