Tags

, , , , ,

We know now Microsoft is pushing the SharePoint development to client side as much as possible. This means developers should use JavaScript more instead of server side code where is possible and Microsoft made this easier by exposing some SharePoint properties to client side code. There is a JavaScript object called _spPageContextInfo which contains some properties you might use in your code:

  • webServerRelativeUrl
  • webAbsoluteUrl
  • siteAbsoluteUrl
  • serverRequestPath
  • layoutsUrl
  • webTitle
  • webTemplate
  • tenantAppVersion
  • isAppWeb
  • webLogoUrl
  • webLanguage
  • currentLanguage
  • currentUICultureName
  • currentCultureName
  • clientServerTimeDelta
  • siteClientTag
  • crossDomainPhotosEnabled
  • webUIVersion
  • webPermMasks
  • pageListId
  • pageItemId
  • pagePersonalizationScope
  • userId
  • systemUserKey
  • alertsEnabled
  • siteServerRelativeUrl
  • allowSilverlightPrompt

List is long and you can figure out yourself how to use them. Probably the most noticeable property is userId. I remember when people moved to SharePoint 2013, a lot of developers were upset they could not use any more _spUserId. That’s probably they did not know it was replaced with _spPageContextInfo.userId. I would say, Microsoft did not communicate enough new functionalities, but this doesn’t mean they did not offer something to replace old functionality.

Advertisements