You can achieve it using recursion. You will have to create two rules. Please find the code blocks of them below.
Name - HS_rule2
a!localVariables(
local!nextId: displayvalue(
ri!id,
ri!data.id,
ri!data.idFather,
null
),
if(
a!isNullOrEmpty(local!nextId),
{},
{
local!nextId,
rule!HS_rule2(
id: local!nextId,
data: ri!data
)
}
)
)
Rule inputs - id (Number (Integer)) & data (Any Type)
Now its parent interface.
Name - HS_rule1
a!localVariables(
local!id: 10,
local!data: {
{ id: 1, idFather: 3 },
{ id: 2, idFather: 5 },
{ id: 3, idFather: 9 },
{ id: 5, idFather: 6 }
},
if(
contains(tointeger(local!data.id),local!id),
{
local!id,
rule!HS_rule2(id: local!id, data: local!data)
},
null
)
)
Change the value of local!id with whatever you want to search and paste your dictionary/CDT in local!data
This will give you a list of all the IDs that are inter-related, in sequential order. Hope that helps!