How to change user language when user have visitor access on SharePoint online site

Umair Aslam 20 Reputation points
2024-04-04T12:13:05.61+00:00

Dear Community,

I am changing user language using following code using SPFx Application Customizer extension.

    sp.web.siteUserInfoList.items
      .getById(this.context.pageContext.legacyPageContext['userId'])
      .update({
        'MUILanguages': `${selectedValue},en-US`
      })
      .then(() => {
        //console.log
        //localStorage.setItem('isFirstReload', 'true');
        if (selectedValue == "ar-AE")
          localStorage.setItem('Language', 'arabic');
        else
          localStorage.setItem('Language', 'english');

        setTimeout(() => {
          window.open(window.location.href,"_blank");
        }, 1000);

      });

This code working fine when user have Edit or more permission but when user have visitors permission I get unauthorize error.
Please suggest me any work around for this issue.

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. Martin Laplante 401 Reputation points
    2024-04-06T18:35:52.4266667+00:00

    The simple answer is change the viewer's permissions to include "Edit personal user information" using the method here.

    https://docs.microsoft.com/en-us/sharepoint/how-to-create-and-edit-permission-levels

    If you want a more complete answer it's too long for here, but you can contact me if you like.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.