How to clear SharePoint People Picker suggestion cache

If you have been SharePoint Site owner long enough, you would have definitely bumped into task like assigning document permission using SharePoint People Picker.
One of the out of the box SharePoint People Picker features is that it auto caches all previous user entry entered/selected by you.

 

This cached people picker entity is meant to help you to quickly find the user and assign the permission.people picker cache issue
It would introduce invalid entry if there is cease of identity provider (for whatsoever reason that the decision made from the IT management needs us to swing the SharePoint identity provider to other platform).

Things could get messier for those who frequently accessing people picker, to be seeing the old cached user.

Another situation that introduce inconsistency is when there is change of user name/job title etc for which is cached and not reflecting the correct info to the end user.

 

SharePoint People Picker uses LocalStorage to cache the people picker entity. In order to flush the cache, you would need to run a JavaScript to clear the cache. What’s worst is that there is no expiration set.
If you fire up your browser development tool and type in “localStorage” (case sensitive) in the console. You would see the cache key/value for ClientPeoplePickerMRU.

hit F12: For Chrome, IE and Firefox (Note:You must be firing up the developer tool at the SharePoint Page)ie people picker localstorage

 

Chrome – Resource tab

chrome people picker localstorage

 

So what can we do?

If you are developer and techie, you can easily fire up the developer console of your browser and run the below JavaScript


localStorage.clear();

If you are helping your end user to flush the cache, one possible way is to provide them a quick custom web part using javascript above to flush their cache. Alternatively, creating a custom JS with leveraging Cookie as expiration check, put it into your home page. Whenever user accessing to your home page, this JS will check from Cookies to see if it is time to Refresh (or clear) the local storage.
The other possible way is to get them clear the Local Storage from their Browser. I couldn’t find where the IE local storage is. If you know, I will be more than happy if you can tell me.

For IE Users who wish to clear the people picker. Here are the steps you may follow
1. Go to page with people picker
2. F12 Developer Tools
a. Console
b. localStorage.clear();
3. Close F12
4. Then refresh the web page to test it.

[Credit goes to Chris for the steps above]

6 thoughts on “How to clear SharePoint People Picker suggestion cache

  1. Chris

    If anyone needs it here are some notes I took as I tested this out. Thanks as this works great!
    Steps: (internet explorer)
    1. Go to page with people picker
    2. F12 Developer Tools
    a. Console
    b. localStorage.clear();
    3. Close F12
    4. Then refresh the web page to test it.

    I added this javascript by using the insert embed code option on a wiki page and got it to work as well.

    localStorage.clear();

    Reply
    1. Chris

      oops the editor removed the script open / close tags around the bottom of my comment. Here it is again.
      <script type=”text/javascript”>
      localStorage.clear();

      </script>

      Reply
  2. Bjarte

    Sounds a little intrusive to clear the full localStorage, here is a script clearing only the people picker cache:

    ExecuteOrDelayUntilScriptLoaded(function () {
    var mru = SPClientPeoplePickerMRU.GetSPClientPeoplePickerMRU();
    mru.ResetCache();
    }, “clientpeoplepicker.js”);

    Reply
    1. Ah Cheng Post author

      Thanks for the tips! I checked, the function is running code window.localStorage.removeItem(“ClientPeoplePickerMRU”).
      Which is a better way of clearing the cache than clearing the entire localStorage.
      Thanks! It worked

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code