Skip to main content
1-Visitor
August 20, 2013
Question

mail-address instead username from userfield in a query-result?

  • August 20, 2013
  • 1 reply
  • 1286 views

Hi @all,

i have a query like this:

im issues --fields=id,<userfield> --qeryDefinition=(bla bla bla...)

If i run this query i get a list which contains item-id and the username from the field <userfield>. But i need the mail-address which is linked to this user. Is it possible to see this mail-address instead of the username? Thanks,

kind regards, Jens

    1 reply

    1-Visitor
    August 20, 2013

    You can take the userid and do a "im.exe viewuser" on it. This kind of thing works out great in powershell. Here's how that would look.

    $users = (im.exe issues --fields=<userfield> --qeryDefinition=(bla bla bla...))

    $emails=$users | foreach { im.exe viewuser $_ | findstr "Email Address" | foreach {$_.split(":").trim() }

    ...of course this just gets you a list of email addresses, like a bulk mail.

    To find an individual user's email would be something like this:

    $aUsersEmail = (im.exe viewuser $users[1] | findstr "Email Address" | foreach {$_.split(":").trim() )[0]

    # where 1 is the number of the desired user in the array, which of course

    # can be a variable derived by scanning the $users array for a desired name

    # The [0] is there because the foreach output will be an array of one.

    Message was edited by: David Hegland (for thie to work as written, we have to get only the user field in the first query. Of course, additional fields can be retrieved individually or in bulk by clever parsing.)

    JensN.1-VisitorAuthor
    1-Visitor
    August 21, 2013

    Hi David,

    thanks, this should be a functional workaround. But it works only with at least two queries, which has to be in an external program or script. I was hoping about something like a parameter für showing userfield-entries in a query

    kind regards, Jens