comparing values of CDT in array

Hello,

 

I have a local variable storing list of CDT as array.

local!b:{
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "1", objectName: "A", parentId: "1"),
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "2", objectName: "B",parentId: "2"),
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "3", objectName: "C", parentId: "2"),
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "4", objectName: "D", parentId: "1"),
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "5", objectName: "E", parentId: "1"
'type!{urn:com:appian:types:folders}CMN_RootCaseFolder'( objectId: "6", objectName: "F", parentId: "2")
},

 

In this array of CDT type, the logic which I am trying to achieve is to check if the array element object id is acting as parent of other array elements present in the same local!b.

For Example: the objectId="1" is present as parentId in 2 elements (objectName=D,E)

Please suggest how to achieve it.

Any response would be appreciated.

Thanks in advance,

Divya

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Hello Divyaa,

     

    To achieve your requirement (For Example: the objectId="1" is present as parentId in array elements) refer below code,

     

    load(
    local!arrRootCaseFolder:{
    type!CMN_RootCaseFolder(
    objectId: 1,
    objectName: "A",
    parentId: 1
    ),
    type!CMN_RootCaseFolder(
    objectId: 2,
    objectName: "B",
    parentId: 2
    ),
    type!CMN_RootCaseFolder(
    objectId: 3,
    objectName: "C",
    parentId: 2
    ),
    type!CMN_RootCaseFolder(
    objectId: 4,
    objectName: "D",
    parentId: 1
    ),
    type!CMN_RootCaseFolder(
    objectId: 5,
    objectName: "E",
    parentId: 1
    ),
    type!CMN_RootCaseFolder(
    objectId: 6,
    objectName: "F",
    parentId: 2
    )
    },
    local!result: index(local!arrRootCaseFolder,whereContains(1,index(local!arrRootCaseFolder,"parentId",0)),""),
    local!result

    )

    Output:

     

    Type

    CMN_RootCaseFolder?list

     
     
    Value

    [objectId=1, objectName=A, parentId=1]; [objectId=4, objectName=D, parentId=1]; [objectId=5, objectName=E, parentId=1]

     
     
     
  • 0
    A Score Level 1
    in reply to jaidw
    Thank you . I was able to move ahead with your solution. But still curious to know how is this kind of looping carried out. In the above example, the whereContains() has 1 as value to be found, but if I have to check through all the CDT list with the value to found is the objectId value present in CDT in whereContains().
Reply Children