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

    Could you give us a little bit more deail about what you need to achive? I,m nor sure If you want to remove the duplicated items, remove the items with a duplicated countryId..... For example, what would you like to get as output in you example?

    Anyway, you can get different countries with local!test1.country, and after that, iterate over them (for each), removing the elements no longer needed

Reply
  • 0
    Certified Lead Developer

    Could you give us a little bit more deail about what you need to achive? I,m nor sure If you want to remove the duplicated items, remove the items with a duplicated countryId..... For example, what would you like to get as output in you example?

    Anyway, you can get different countries with local!test1.country, and after that, iterate over them (for each), removing the elements no longer needed

Children