How to get a User object from "user name "

I can only see a method, to get User object from UserId.

If you’re using the Users module from:

import { Users } from "@foundry/functions-api";

Then yes, there are only two methods to get it and they’re by Id.

I can think of a few alternatives:

  1. You can use Foundry API to create an object type with all the users (API Docs) and then search on it.

    Response:

    {
      "data": [
        {
          "givenName": "John",
          "familyName": "Smith",
          "organization": "ri.multipass..organization.c30ee6ad-b5e4-4afe-a74f-fe4a289f2faa",
          "realm": "palantir-internal-realm",
          "attributes": {
            "multipass:givenName": [
              "John"
            ],
            "multipass:familyName": [
              "Smith"
            ],
            "multipass:email:primary": [
              "jsmith@example.com"
            ],
            "multipass:realm": [
              "eab0a251-ca1a-4a84-a482-200edfb8026f"
            ],
            "multipass:organization-rid": [
              "ri.multipass..organization.c30ee6ad-b5e4-4afe-a74f-fe4a289f2faa"
            ],
            "department": [
              "Finance"
            ],
            "jobTitle": [
              "Accountant"
            ]
          },
          "id": "f05f8da4-b84c-4fca-9c77-8af0b13d11de",
          "email": "jsmith@example.com",
          "username": "jsmith"
        }
      ],
      "nextPageToken": "v1.VGhlcmUgaXMgc28gbXVjaCBsZWZ0IHRvIGJ1aWxkIC0gcGFsYW50aXIuY29tL2NhcmVlcnMv"
    }
    
  2. List all the users in a given group and search in Type Script

  3. Use MP attributes in workshop if this is related somehow to the current user.

1 Like