_spPageContextInfo in SharePoint 2016

SharePoint 2016 has been released with so many cool features. This document aims to discuss what’s new in _spPageContextInfo in SharePoint 2016. _spPageContextInfo is very much helpful for any kind of JSOM development. End of this document, we will also see a comparison matrix of _spPageContextInfo (2013 vs 2016 vs Online).

What is _spPageContextInfo

_spPageContextInfo is a global variable. It belongs to any pages like wiki, publishing and system pages. It provides us so many useful information about the web by its properties. For example, _spPageContextInfo.userLoginName gives the login name of the current logged in user. If we do not have this property in _spPageContextInfo, then we had to make a REST call to get this.

What’s new in 2016

Following properties are new in SharePoint 2016

Property Name Description
isAppWeb  It will return true if your current web is an app web.
updateFormDigestPageLoaded  It’s a date time object meaning when your form digest has been updated.
userLoginName  Login name of the current user.
isSiteAdmin  It will return true if current user is the admin of current site.
ProfileUrl  It will give you the my site URL of current user.

Comparison matrix (2013 vs 2016 vs Online)

Comparison matrix of _spPageContextInfo (2013 vs 2016 vs Online) is given below.

Name 2013 2016 Online
webServerRelativeUrl Yes Yes Yes
webAbsoluteUrl Yes Yes Yes
siteAbsoluteUrl Yes Yes Yes
serverRequestPath Yes Yes Yes
layoutsUrl Yes Yes Yes
webTitle Yes Yes Yes
webTemplate Yes Yes Yes
tenantAppVersion Yes Yes Yes
isAppWeb No Yes Yes
hasManageWebPermissions No No Yes
webLogoUrl Yes Yes Yes
webLanguage Yes Yes Yes
currentLanguage Yes Yes Yes
currentUICultureName Yes Yes Yes
currentCultureName Yes Yes Yes
clientServerTimeDelta Yes Yes Yes
updateFormDigestPageLoaded No Yes Yes
siteClientTag Yes Yes Yes
crossDomainPhotosEnabled Yes Yes Yes
webUIVersion Yes Yes Yes
webPermMasks Yes Yes Yes
pageListId Yes Yes Yes
pageItemId Yes Yes Yes
pagePersonalizationScope Yes Yes Yes
userId Yes Yes Yes
userLoginName No Yes Yes
systemUserKey Yes Yes Yes
isAnonymousGuestUser No No Yes
alertsEnabled Yes Yes Yes
siteServerRelativeUrl Yes Yes Yes
allowSilverlightPrompt Yes Yes Yes
themeCacheToken No No Yes
isSiteAdmin No Yes Yes
env No No Yes
ProfileUrl No Yes Yes

Conclusion

That’s all about  _spPageContextInfo in SharePoint 2016. I hope you will enjoy it and feel always welcome to let me know your feedback.

Leave a Reply