Return Value In Dictionary

I have this dictionary that I want to extract values from depending on one of its values:

a!localVariables(
  local!myDictionary: {
    {
      user : 
      {
          info :{
            { 
              name: {codeValue: 1, nameValue: "engineer"}, type : { codeValue: "role", nameValue: "role" }
            },
            { 
              name: {codeValue: "s101", nameValue: "science"}, type : { codeValue: "dept", nameValue: "dept" }
            }
          }
      }
    },
    {
      user: { {},{} }
    }
  },
  local!tempResults:
  //maybe too much going on
  index(
    if(isnull(property(local!myDictionary.user,"info",null)),"",local!myDictionary.user.info)
    ,if(isnull(property(local!myDictionary.user,"info",null)),"",wherecontains("role",touniformstring(local!myDictionary.user.info.type.nameValue))),""),
  local!tempResults
)

I'm wanting to return either the 'codeValue' or 'nameValue' from 'name' (ie.1,engineer,s101,science), depending if the 'type' has either a 'codeValue/nameValue' of either "role" or "dept". I want both of the object results to return as well, with the second 'user' object just being an empty string (""). 

With this it looks like its just getting the last item out and on the second 'user' object, it is empty and comes back null and the property doesn't exist so it throws an error and why I used the property() function often to cancel the error, but I feel like its too much for maybe something simple. Any suggestions are appreciated.

  Discussion posts and replies are publicly visible