How to get only single sub record form list of dictionary?

Hi Team,

I have list of dict. like:

{{{customername: "Hardy", name: "S1", region: "Asia"}}, 
{{customername: "Len",name: "SRD", region: "NA"}},
{{customername: "MAdusa", name: "Line 9", region: "Australia"}}}

Now I want to store only name values in a local variable.

I need result like, '

local!variable1 = { "S1","SRD","Line 9" }

how to do this with loop ?

Because list of dict. can be more or less or empty so need code which can handle if the list comes empty(can return null), I will be using this code in expression rule

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The simplest way that works in most cases is to just access the dot property, i.e. "local!myList.customerName", which is NOT null-safe; the null-safe alternative is the Property() function - i.e. "property(local!myList, "customerName", {})", which returns an empty set as a default if the list is empty or no such property is found.

    a!localVariables(
      local!list: {
        {
          customername: "Hardy",
          name: "S1",
          region: "Asia"
        },
        {
          customername: "Len",
          name: "SRD",
          region: "NA"
        },
        {
          customername: "MAdusa",
          name: "Line 9",
          region: "Australia"
        }
      },
      
      local!emptyList: {},
      
      "Customer Names (populated list): " & property(local!list, "customername", {}) 
      & char(10) & char(10)
      & "Customer Names (empty list): " & property(local!emptyList, "customername", {})
      
    )

  • I tried but it works on list of dict. but not on my type i.e

Reply Children