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.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,832 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,706 questions
0 comments No comments
{count} votes

Accepted answer
  1. Martin Laplante 316 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