There are two pagelists say GrandFatherPage.pxResults and FatherPage.pxResults. The property ID in Grandfateher pagelist can have the common value with the property FID in Father Pagelist. There are multiple pages in Father Pagelist that have common value for the ID of a Page in GrandFather Pagelist.
I would like to copy all the properties from a page of Father Pagelist based on the following conditions.
The GrandFatherPage().ID equals the Father().FID
If the Father().Status has value equals to “Fail”, copy from the first occurring page.
If the Father().Status does not have “Fail” in any of the pages, copy from the last occurring page.
If above conditions (1 AND 2) OR (1 AND 3) are not true, no page should be copied.
What configurations in data transform resolve it? Thank you in advance. I have attached sample screenshot from clipboard.
I know the Activities are not best practice but IMHO this is best to solve such use case, I think it will be hard to implement this in DT as you need to iterate over two datapages. I would suggest to do it in activity as you may need to store one page temporarly:
In this when condition you will have current FatherPage page as TMP and current GrandFatherPage as stepPage.
I don't fully understand the logic you described so I didn't fully implement it, but I think the DT could be hard to implement here.
Thank you for the details. Shall we explore data transform options? Looping over FatherPage, getting the FID, and Status in Param and looping to GrandFatherPage under father page with the when conditions correctly gives the result if one of the FatherPage has Status as 'Fail' (please see below screenshot Father name is copied to pyNote as an example). However, when all pages in FatherPage has status 'Pass', the GrandFatherPage needs to have the FatherName set to pyNote from the last page of the FatherPage that is Bob Junior 3. So basically, we would like to have the data from one page that has Status as Fail, if there are multiple fails we take the first over iteration exit for the rest. If no page has fail, we go until the last page that matches GrandFather.ID=Father.FID and get the FatherName set from that page to the GrandFatherPage.pyNote. Please let me know if you need additional details to solve it.
Okay, so it doesn't sound like it is a 1 to 1 mapping and is instead possible for FatherPage.pxResults to contain 0, 1 or more matching pages with the same FID as GrandFatherPage.pxResults(<current>).ID
If that is the case, then I think what was previously suggested - to use an activity - is probably your best course of action.
You can do this by starting your loop through each embedded page in GrandFatherPage.pxResults
You would then have a java step where you can call a function @Utilities.findInPageList(lookFor, lookAt, lookIn)
lookFor = .ID
lookAt = ".FID"
lookIn = FatherPage.pxResults
This will return you an ArrayList of pages that matched where the FID matches the current GrandFatherPage.pxResults().ID
You can then iterate through the ArrayList and if you encounter an instance where Status == Fail, then you just copy the results from ArrayList index 0. Otherwise, you copy results from ArrayList index last.