Merge muliple columns from resultset dynamically

I have a datasubset DS containing properties X, Y and others. I am trying to take the property X and Y dynamically and do the merge ( property names are passed dynamically ).

Below script didnt work because apply is returning a single array with all the values for X and Y. Is there any other way to do it?

local!propertyName_txts: {
    "X",
    "Y"
  },
  merge(
    apply(
      fn!property(
        local!DS_ds.data,
        _
      ),
      local!propertyName_txts
    )
  )

 

  Discussion posts and replies are publicly visible

Parents
  • Hello Bbalasubramanik,

    which version of Appian are you using?

    I don't fully understand what you want to achieve. But I did the test and I got the following:

     

    with(
    local!data :{{X:"x1", Y:"Y1", Z:"Z1"},
    {X:"x2", Y:"Y2", Z:"Z2"},
    {X:"x3", Y:"Y3", Z:"Z3"},
    {X:"x4", Y:"Y4", Z:"Z4"},
    {X:"x5", Y:"Y5", Z:"Z5"}} ,
    local!DS_ds:a!dataSubset(startIndex:1,batchSize:100, totalCount:5, data:local!data, identifiers:local!data.X),
    local!propertyName_txts: {
        "X",
        "Y"
      },
      merge(
        apply(
          fn!property(
            local!DS_ds.data,
            _
          ),
          local!propertyName_txts
        )
      )
    
     )

     

    This is what I Got 

    Test OutputHide section contents
    
    Time	
    2 ms
    Type	
    List of Variant
    Value	
    List of Variant: 2 items
        List of Variant: 5 items
            "x1"
            "x2"
            "x3"
            "x4"
            "x5"
        List of Variant: 5 items
            "Y1"
            "Y2"
            "Y3"
            "Y4"
            "Y5"

    What are you expecting to get? 

    This is what I got
    {
    {"x1", "x2", "x3", "x4", "x5"},
    {"Y1", "Y2", "Y3", "Y4", "Y5"}
    }

     

    do you want to obtain something like this?

    {{"x1","Y1"},
    {"x2","Y2"},
    {"x3","Y3"},
    {"x4","Y4"},
    {"x5","Y5"}}

    If you are using V17.2 maybe this will help

    with(
      local!data: {
        {X: "x1",Y: "Y1",Z: "Z1"},
        {X: "x2",Y: "Y2",Z: "Z2"},
        {X: "x3",Y: "Y3",Z: "Z3"},
        {X: "x4",Y: "Y4",Z: "Z4"},
        {X: "x5",Y: "Y5",Z: "Z5"}
      },
      local!DS_ds: a!dataSubset(
        startIndex: 1,
        batchSize: 100,
        totalCount: 5,
        data: local!data,
        identifiers: local!data.X
      ),
      local!propertyName_txts: {
        "X",
        "Y"
      },
      a!forEach(
        items: local!DS_ds.data,
        expression: {
          with(
            local!tempData: fv!item,
            a!forEach(
              items: local!propertyName_txts,
              expression: with(
                local!propertyName: fv!item,
                property(
                  local!tempData,
                  local!propertyName
                )
              )
            )
          )
        }
      )
    )

     

    Jose Perez

Reply
  • Hello Bbalasubramanik,

    which version of Appian are you using?

    I don't fully understand what you want to achieve. But I did the test and I got the following:

     

    with(
    local!data :{{X:"x1", Y:"Y1", Z:"Z1"},
    {X:"x2", Y:"Y2", Z:"Z2"},
    {X:"x3", Y:"Y3", Z:"Z3"},
    {X:"x4", Y:"Y4", Z:"Z4"},
    {X:"x5", Y:"Y5", Z:"Z5"}} ,
    local!DS_ds:a!dataSubset(startIndex:1,batchSize:100, totalCount:5, data:local!data, identifiers:local!data.X),
    local!propertyName_txts: {
        "X",
        "Y"
      },
      merge(
        apply(
          fn!property(
            local!DS_ds.data,
            _
          ),
          local!propertyName_txts
        )
      )
    
     )

     

    This is what I Got 

    Test OutputHide section contents
    
    Time	
    2 ms
    Type	
    List of Variant
    Value	
    List of Variant: 2 items
        List of Variant: 5 items
            "x1"
            "x2"
            "x3"
            "x4"
            "x5"
        List of Variant: 5 items
            "Y1"
            "Y2"
            "Y3"
            "Y4"
            "Y5"

    What are you expecting to get? 

    This is what I got
    {
    {"x1", "x2", "x3", "x4", "x5"},
    {"Y1", "Y2", "Y3", "Y4", "Y5"}
    }

     

    do you want to obtain something like this?

    {{"x1","Y1"},
    {"x2","Y2"},
    {"x3","Y3"},
    {"x4","Y4"},
    {"x5","Y5"}}

    If you are using V17.2 maybe this will help

    with(
      local!data: {
        {X: "x1",Y: "Y1",Z: "Z1"},
        {X: "x2",Y: "Y2",Z: "Z2"},
        {X: "x3",Y: "Y3",Z: "Z3"},
        {X: "x4",Y: "Y4",Z: "Z4"},
        {X: "x5",Y: "Y5",Z: "Z5"}
      },
      local!DS_ds: a!dataSubset(
        startIndex: 1,
        batchSize: 100,
        totalCount: 5,
        data: local!data,
        identifiers: local!data.X
      ),
      local!propertyName_txts: {
        "X",
        "Y"
      },
      a!forEach(
        items: local!DS_ds.data,
        expression: {
          with(
            local!tempData: fv!item,
            a!forEach(
              items: local!propertyName_txts,
              expression: with(
                local!propertyName: fv!item,
                property(
                  local!tempData,
                  local!propertyName
                )
              )
            )
          )
        }
      )
    )

     

    Jose Perez

Children