How to keep only unique items based on the specific key. In this case countryId . Data type is List of Dict

local!test1: {
{
item: "stapler",
name: "Mike",
countryId: 1
},
{
item: "printer",
name: "Larry",
countryId: 2
},
{
item: "laptop",
name: "Mike",
countryId: 1
},
{
item: "glass",
name: "Mike",
countryId: 3
}
},

  Discussion posts and replies are publicly visible

Parents
  • {
    a!localVariables(
    local!test1: {
    {
    item: "stapler",
    name: "Mike",
    countryId: 1
    },
    {
    item: "printer",
    name: "Larry",
    countryId: 2
    },
    {
    item: "laptop",
    name: "Mike",
    countryId: 1
    },
    {
    item: "glass",
    name: "Mike",
    countryId: 3
    }
    },
    local!unique: union(local!test1.countryId,local!test1.countryId),
    local!res: a!forEach(
    items: local!unique,
    expression: index(local!test1,index(wherecontains(tointeger(fv!item),tointeger(local!test1.countryId)),1,null),null)
    ),
    local!res
    )

    }

Reply
  • {
    a!localVariables(
    local!test1: {
    {
    item: "stapler",
    name: "Mike",
    countryId: 1
    },
    {
    item: "printer",
    name: "Larry",
    countryId: 2
    },
    {
    item: "laptop",
    name: "Mike",
    countryId: 1
    },
    {
    item: "glass",
    name: "Mike",
    countryId: 3
    }
    },
    local!unique: union(local!test1.countryId,local!test1.countryId),
    local!res: a!forEach(
    items: local!unique,
    expression: index(local!test1,index(wherecontains(tointeger(fv!item),tointeger(local!test1.countryId)),1,null),null)
    ),
    local!res
    )

    }

Children
No Data