Protiviti / SharePoint Blog

SharePoint Blog

September 27
New additions to _spPageContextInfo in Office 365


Microsoft is constantly expanding its Office 365 offerings. When discussing SharePoint specifically, we’ve all heard of the major overhaul changes to the UI that are coming. This is all very good news as in addition to the visuals, the back-end is getting a major overhaul. I’d like to shed some light on some of the JavaScript additions and changes that have made their way into the SharePoint Classic / Publishing pages.

_spPageContextInfo:

This handy variable has expanded quite a bit in Office 365, especially compared to 2013.  There are many things asked of us on the client development side and SharePoint always makes it difficult to fulfill every request.  The _spPageContextInfo variable helps immensely with boilerplate data fetching and the 365 changes are signifigant.  Check out the zoomed out diff screenshot.



 
My favorites compared to 2013 include:

  • User’s Time Zone Setting (_spPageContextInfo.userTimeZoneData)
  • Web’s Time Zone Steting (_spPageContextInfo.webTimeZoneData): If user doesn’t have one set, fall back to this
  • User’s login Name (_spPageContextInfo.userLoginName)
  • User’s Display Name (_spPageContextInfo.userDisplayName)
  • List ID where current item is from (_spPageContextInfo.listId)
  • Group Color (_spPageContextInfo.groupColor)
  • Site Color (_spPageContextInfo.siteColor)

Quick Launch


© Protiviti 2018. All rights reserved.   |   Privacy Policy