Skip to main content
April 27, 2023
Question

How can we stop recursion in Hierarchy tree?

  • April 27, 2023
  • 2 replies
  • 0 views

a!localVariables(
  local!path:{
    id:"1",
    name:"Method",
    type: "331324",
    numberOfChildren: 3,
    isDrillable: true,
    image:cons!EA_EMP
  },
  local!name:{
    {
      id:"1",
      name:"Section 1",
      subnodes:{
        {title:"subsection 1.1",
        id:"100",
        type:"264447",
        numberOfChildren:0,
        isDrillable:true,
        image:cons!EA_FEMALEEMP},
        {
          title:"subsection 1.2",
          id:"200",
          type:"264447",
          numberOfChildren:0,
          isDrillable:true,
          image:cons!EA_MALEEMP1
        }
      },
      type:"264447",
      numberOfChildren:1,
      isDrillable:true,
      image:cons!PT_SUPERVISOR_1
    },
    {
      {
        id:"2",
        name:"Section 2",
        subnodes:{
          {title:"subsection 2.1",
          id:100,
          type:"264447",
          numberOfChildren:1,
          isDrillable:true,
          image:cons!PT_SUPERVISOR_1},
          {
            title:"subsection 2.2",
            id:200,
            type:"264447",
            numberOfChildren:0,
            isDrillable:true,
            image:cons!EA_EMP
          }
        },
        type:"264447",
        numberOfChildren:2,
        isDrillable:true,
        image:cons!EA_EMPMALE
      },
      {
        id:"3",
        name:"Section 3",
        subnodes:{
          {title:"subsection 3.1",
          id:100,
          type:"264447",
          numberOfChildren:0,
          isDrillable:true,
          image:cons!EA_FEMALEEMP1
          },
          {
            title:"subsection 3.2",
            id:200,
            type:"264447",
            numberOfChildren:0,
            isDrillable:true,
            image:cons!EA_FEMALEEMP
          }
        },
        type:"264447",
        numberOfChildren:1,
        isDrillable:false(),
        image:cons!EA_MALEEMP1
      },
    }
  },
  a!hierarchyBrowserFieldTree(
    pathValue: local!path,
    pathSaveInto: local!path,
    nextLevelValues: a!forEach(
      
      items: enumerate(fv!nodeValue.numberOfChildren),
      expression: a!localVariables(
        local!numberOfChilren: index(local!name[fv!index],"numberOfChildren",0),
        local!isDrillable:index(local!name[fv!index],"isDrillable",false),
        {
          id: local!name[fv!index].id,
          name: local!name[fv!index].name,
          subnodes:local!name[fv!index].subnodes,
          title:local!name.subnodes.title,
          type: local!name[fv!index].type,
          image:local!name[fv!index].image,
          numberOfChildren: local!numberOfChilren,
          isDrillable: local!isDrillable
        }
      )
    ),
    nodeConfigs: a!hierarchyBrowserFieldTreeNode(
      id: fv!nodeValue.id,
      label: fv!nodeValue.name,
      description: {fv!nodeValue.subnodes.title},
      image: a!documentImage(
        document: fv!nodeValue.image
      ),
      isDrillable: true(),
      nextLevelCount: fv!nodeValue.numberOfChildren,
      showWhen: true()
    )
  )
)

I'm new to appian, can anyone clarify my doubt related to HierarchicalBrowserFieldTree

1.How can i stop recursion as I need subsections under sections but the same section fields are looping continuously

2 replies

stefanhelzle0001
Brainy
April 27, 2023

stefanhelzle0001
Brainy
April 27, 2023

But you built your code to do exactly that ?!? It seems like your code for "nextLevelValues" returns all items, not just the real children.