Val() not working - what I'm doing wrong?

I got a solution a couple of threads below.

upsert {
 query {
checkNameNew(func: eq(user_id, "4")) {
      newusername as username
}	

 qName(){
        nu as max(val(newusername))
      }
  
userB as var(func: eq(user_id, "6"))

}

mutation {
	set {
			uid(userB) <username> val(nu) .
	}
}

}