Forum Discussion

Tarang_7's avatar
Tarang_7
Copper Contributor
Nov 04, 2025

Sharepoint Webpart Discussion

I make a webpart using react language in that webpart I have create a form in that I have a dropdown in that I want to display all users of my community 
but currently only site users are displayed 

These are all the required code lines for populating dropdown :-

const [users, setUsers] = React.useState<IDropdownOption[]>([]);

const userResults = await sp.web.siteUsers();

      const userOptions: IDropdownOption[] = userResults.map(user => ({

        key: user.Id.toString(),

        text: user.Title

      }));


<Dropdown

            label="Assigned To"

            options={users}

            selectedKeys={assignedToUsers}

            onChange={(_, option) => {

              if (!option) return;

              setAssignedToUsers(prev =>

                option.selected

                  ? [...prev, option.key as string]

                  : prev.filter(k => k !== option.key)

              );

            }}

            placeholder="Select Assigned to person(s)"

            multiSelect

            styles={{ dropdown: { width: "100%", marginTop: 10 } }}

          /> }


For displaying all user I also tried the Microsoft Graph Api and changed according to that but these won't work so I now I am finding alternate option so please tell me if you have any solution

1 Reply

  • DavidJacob's avatar
    DavidJacob
    Brass Contributor

    Use the Microsoft Graph API with the `User.Read.All` permission.

     

    const userResults = await graphClient.api('/users').get();


    This will get all tenant users, not just the site users.

Resources