iterate over a map key

Certified Lead Developer

Hi Champs,

I have a map value having multiple key and value pair. Now I want to check for a value which exists in one or more key. So I guess the only way to do that is to iterate over the keys in the map. 

How can I achieve the same. As of my knowledge, for each works for no of map not for no of key/value pair in a map.

Regards,

Ghanashyam

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    remember that a!keys() grabs all keys (as a text array) in a particular dictionary, which you can grab into a local variable and then iterate over.  As Stefan pointed out, you can't push new values into the existing map, but if (as your post implies) you only need to check which keys contain a certain value, then this should work fine.  It should work similarly to Tim's suggested code except you wouldn't need to hardcode your key values in the "local!definedKeys" variable, you'd just use a!keys() there pointed to your map variable.

Reply
  • 0
    Certified Lead Developer

    remember that a!keys() grabs all keys (as a text array) in a particular dictionary, which you can grab into a local variable and then iterate over.  As Stefan pointed out, you can't push new values into the existing map, but if (as your post implies) you only need to check which keys contain a certain value, then this should work fine.  It should work similarly to Tim's suggested code except you wouldn't need to hardcode your key values in the "local!definedKeys" variable, you'd just use a!keys() there pointed to your map variable.

Children
No Data