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
  • +1
    Certified Lead Developer

    a!localVariables(
      local!test1: {
        {
          item: "stapler",
          name: "Mike",
          countryId: 1
        },
        {
          item: "printer",
          name: "Larrys",
          countryId: 2
        },
        {
          item: "printer",
          name: "Larry",
          countryId: 2
        },
        {
          item: "laptop",
          name: "Mike",
          countryId: 1
        },
        {
          item: "glass",
          name: "Mike",
          countryId: 3
        }
      },
    
    
      a!forEach(
        items: union(local!test1.countryId,local!test1.countryId),
        expression: displayvalue(
          fv!item,
          local!test1.countryId,
          local!test1,
          null
        )
      )
    )

Reply
  • +1
    Certified Lead Developer

    a!localVariables(
      local!test1: {
        {
          item: "stapler",
          name: "Mike",
          countryId: 1
        },
        {
          item: "printer",
          name: "Larrys",
          countryId: 2
        },
        {
          item: "printer",
          name: "Larry",
          countryId: 2
        },
        {
          item: "laptop",
          name: "Mike",
          countryId: 1
        },
        {
          item: "glass",
          name: "Mike",
          countryId: 3
        }
      },
    
    
      a!forEach(
        items: union(local!test1.countryId,local!test1.countryId),
        expression: displayvalue(
          fv!item,
          local!test1.countryId,
          local!test1,
          null
        )
      )
    )

Children