Not able to populate data from nested CDT on grid

Hello,

 

I have array of CDT within CDT. When I'm trying to populate data from that array to grid column I'm getting blank value with index function.

CDT Structure:

 

Datasubset value:[ userAssignedRequestName="test",
      users=[userName=dc_creator, email=dc_creator@bankcorp.com, phone=410-858-8811, firstName=test User, lastName=, status=active, role=xxxx, lastUserAction=creator];
            [userName=dc_modifier, email=dc_modifier@bankcorp.com, phone=410-858-8812, firstName=test User2, lastName=, status=active, role=xxxx, lastUserAction=modifier]]; 

Below code is not returning user array:

  a!gridTextColumn(
                  label: "User Name",
                  field: "lastUpdatedUserId",
                  data: rule!REST_getLastUpdatedUser(
                    index(                           
                              local!datasubset.data,
                             "users",
                             {}
                           )                  
                        )
                   ),

above highlighted code is not returning users array. Can anyone faced this issue with nested CDT ?

inside rule rule!REST_getLastUpdatedUser I have logic to return particular user name.

  Discussion posts and replies are publicly visible

Parents
  • Hi Tushar,

    I am suspecting that "you have already applied data while fetching the datasubset in query entity". Please remove data in index and tried the below.

     a!gridTextColumn(

                     label: "User Name",

                     field: "lastUpdatedUserId",

                     data: rule!REST_getLastUpdatedUser(

                       index(                          

                                 local!datasubset,

                                "users",

                                {}

                              )                  

                           )

                      ),

     

    below code is working for me (For time being I have hard coded values)

    load(
    local!data: {
    userAssignedRequestName: "test",
    users: {
    {
    userName: "dc_creator",
    email: "dc_creator@bankcorp.com",
    phone: "410-858-8811",
    firstName: "test User",
    lastName: "",
    status: "active",
    role: "xxxx",
    lastUserAction: "creator"
    },
    {
    userName: "dc_modifier",
    email: "dc_creator@bankcorp.com",
    phone: "410-858-8811",
    firstName: "test User",
    lastName: "",
    status: "active",
    role: "xxxx",
    lastUserAction: "modifier"
    }
    }
    },
    local!pagingInfo: topaginginfo(
    1,
    - 1
    ),
    a!gridField(
    label: "Grid",
    totalCount: 2,
    columns: {
    a!gridTextColumn(
    label: "User Name",
    field: "lastUpdatedUserId",
    data: index(
    local!data,
    "users",
    {}
    )
    )
    },
    value: local!pagingInfo,
    saveInto: local!pagingInfo

     

    Thanks

    Siva Chimata

  • Hi Siva,
    I tried your code it worked as desired. But I am trying to display only two fields instead of all the fields in user.
    I used this in data: index(index(local!data,"users",{}),"userName",,{}) and it worked fine returning the username.
    but when I tried this index(index(local!data,"users",{}),{"userName","lastname"},{}) it went back again to displaying all the fields.
    Can you suggest me how to display only few fields say username and lastname.
    Thanks,
    Yeswanth.
  • Hi Yeswanth,

    Please try the below code to display the Grid Text Column.

    a!gridTextColumn(
    label: "User Name",
    field: "lastUpdatedUserId",
    data: a!forEach(
    items: merge(index(
    index(
    local!data,
    "users",
    {}
    ),
    "userName",
    {}
    ),
    index(
    index(
    local!data,
    "users",
    {}
    ),
    "firstName",
    {}
    )),
    expression: concat(fv!item[1]," ",fv!item[2])
    )
    )


    Hope it helps!!!


    Thanks,
    Hema
  • Hi Yeswanth,

    Use below code.

    load(

    local!data: {

    userAssignedRequestName: "test",

    users: {

    {

    userName: "dc_creator",

    email: "dc_creator@bankcorp.com",

    phone: "410-858-8811",

    firstName: "test User",

    lastName: "Siva",

    status: "active",

    role: "xxxx",

    lastUserAction: "creator"

    },

    {

    userName: "dc_modifier",

    email: "dc_creator@bankcorp.com",

    phone: "410-858-8811",

    firstName: "test User",

    lastName: "Chimata",

    status: "active",

    role: "xxxx",

    lastUserAction: "modifier"

    }

    }

    },

    local!pagingInfo: topaginginfo(

    1,

    - 1

    ),

    a!gridField(

    label: "Grid",

    totalCount: 2,

    columns: {

    a!gridTextColumn(

    label: "User Name",

    field: "userName",

    data: index(

    local!data.users,

    "userName",

    {}

    )

    ),

    a!gridTextColumn(

    label: "Last Name",

    field: "lastName",

    data: index(

    local!data.users,

    "lastName",

    {}

    )

    )

    },

    value: local!pagingInfo,

    saveInto: local!pagingInfo

    )

    )

    Hope this will work

     

    Thanks

    Siva Chimata

Reply
  • Hi Yeswanth,

    Use below code.

    load(

    local!data: {

    userAssignedRequestName: "test",

    users: {

    {

    userName: "dc_creator",

    email: "dc_creator@bankcorp.com",

    phone: "410-858-8811",

    firstName: "test User",

    lastName: "Siva",

    status: "active",

    role: "xxxx",

    lastUserAction: "creator"

    },

    {

    userName: "dc_modifier",

    email: "dc_creator@bankcorp.com",

    phone: "410-858-8811",

    firstName: "test User",

    lastName: "Chimata",

    status: "active",

    role: "xxxx",

    lastUserAction: "modifier"

    }

    }

    },

    local!pagingInfo: topaginginfo(

    1,

    - 1

    ),

    a!gridField(

    label: "Grid",

    totalCount: 2,

    columns: {

    a!gridTextColumn(

    label: "User Name",

    field: "userName",

    data: index(

    local!data.users,

    "userName",

    {}

    )

    ),

    a!gridTextColumn(

    label: "Last Name",

    field: "lastName",

    data: index(

    local!data.users,

    "lastName",

    {}

    )

    )

    },

    value: local!pagingInfo,

    saveInto: local!pagingInfo

    )

    )

    Hope this will work

     

    Thanks

    Siva Chimata

Children
No Data