How to get Username using user_id

Hi,

I need to fetch the username by using user_id.
I am getting user_id from the inventory log.

query {
inventory_changes(date_from: “2021-05-30”) {
request_id
complexity
data {
edges {
node {
user_id
account_id
warehouse_id
sku
previous_on_hand
change_in_on_hand
reason
cycle_counted
location_id
created_at
}
}
}
}
}

How to get the username(Inventory Changed By) using user_id.

Thanks in advance.

Hi @supritha ,
What is the request-id that is returned so I can take a closer look?

This query will give the user name:

query {
  picks_per_day(date_from: "2021-04-30") {
    request_id
    complexity
    data {
      edges {
        node {
          id
          user_id
          tote_id
          line_item_id
          location_id
          order_id
          order_number
          user_first_name
          user_last_name
          inventory_bin
          sku
          quantity
          picked_quantity
          pick_type
          barcode_scanned
          created_at
        }
        cursor
      }
    }
  }
}
1 Like

Thanks, @Theresa!

Yes, I got a user name using the mentioned Query.

1 Like

Hi,

Is there any case where user_id returned from inventory_changes API is not in packs_per_day to fetch user_first_name?
User Id returned from inventory_changes query, for all those id’s can we get the username from packs_per_day.

query {
        packs_per_day(user_id: ${userId}) {
          request_id  
          complexity
          data {
            edges {
              node {
                user_first_name
                user_last_name
              }
            }
          }
        }
      }

Thanks in advance.

Hi
If you get a userId, the query should return a result as long as the user did pack on that day.

Hi,
So this query will return username only if that user packed on that day.
If the user does an inventory change and will not pack on that day, this query will not return the username.
Can I get any other query where fetching username using user_id is not dependent on any other thing?

2 Likes

Is there any other API to fetch username using user id, which is not dependent on packs_per_day?

Hi @supritha!

We apologize for the delayed response about this.
We have made an internal request to add this either to a new query or to the account query as a connection.
Thanks again for the patience and we will keep you updated on the progress of the request!
Tom

I am interested in this as well.

We’re linking picks_per_day + packs_per_day data to our timesheet data. User first name + last name are a bit weak as far as keys go, so we’re hoping to translate user IDs to email addresses and link those to timesheets.

1 Like

Thanks @askthebird !
Added a +1 on our internal request :slightly_smiling_face:

2 Likes