An update to this one. %root_nodes%
works because we were using two asset lists. The first returned parent folders, the second returned the Data Assets in those folders. In that context %root_nodes%
referred to the parent folder so worked as we wanted.
We’ve since updated this so that we’re just using a single asset listing to list the Data Records, but that means %root_nodes%
now returns an array of IDs for a given asset instead of printing each separately with its associated parent in context - back to square one.
Under these circumstances we end up with something that looks like:
1111 - 2222, 3333, 4444
We were able to get them printing separately by using a level 1 folder grouping which got us back to:
1111 - 2222
1111 - 2222
1111 - 2222
Same problem as in the original. The question is how to retrieve the right parent for the asset in context.
In this case, the relevant parent would be the grouping that the asset is being printed within, but there’s no %asset_parent_grouping%
keyword to do this easily from the Default Format bodycopy. In the Group Format bodycopy you can use %parent_assetid%
to retrieve the ID of the current group - this is exactly what we want.
The solution here was to use SSJS in the Group Format bodycopy to assign the %parent_assetid%
value to a SSJS variable and then to print that variable from the Default Format bodycopy.
Group Format bodycopy:
<script runat="server">var id = "%parent_assetid%";</script>%group_listing%
Default Formart bodycopy:
%asset_assetid% - <script runat="server">print(id);</script>
The result is:
1111 - 2222
1111 - 3333
1111 - 4444
Thought it might be worth recording this in case others have the same trouble.