TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
An Overview of PageState
Uday Joshi
May 21, 2016
3.8
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
Discussion about yet another SharePoint JavaScript global variable.
If you are a SharePoint techie, I bet _spPageContextInfo is your best friend! I am not an orator, but rather a SharePoint techie like you who has been extensively using _spPageContextInfo to reduce server round trips considerably in our JSOM customization for SharePoint. Sahil Malik wrote a great
post
to introduce _spPageContextInfo.
There are a few requirements, especially with publishing pages where we would like to use the properties of the current page and the current web. And most of us might have implemented an asynchronous call followed by clientcontext.load to get these properties for the current page or web. I was pondering over how we can check if the current page is published or not and then I stumbled upon PageState - another global variable. I thought to post the properties of this object just in case it might be useful for someone.
As you can see, most of the properties are self explanatory, so I will not be describing them here. But there is something about these properties that I must mention. The properties that are not set for the current page, are absent (as we must have expected that they are set to '0' instead of a '1' in the value column). For example, if we check out the page and just save it without checking in, the 'ItemIsMajorVersion' property would simply be missing from this list.
As a second example, you can see that '
ItemIsCheckedOutToCurrentUser
' property appears in the list when I checked the page out:
Before you get too exited about this, I must share a word of caution here. PageState belongs to the SP.Ribbon.js library, it would have a value 'undefined' if the ribbon is hidden from the page (one way to hide the ribbon is to select 'Hide Ribbon' option from the Site Actions menu. This option is disabled when the page is checked out, and this means that PageState would definitely be available for a checked out page).
Interesting isn't it? I would encourage you to explore different properties of the PageState variable with F12 and share your observations with all of us.
SharePoint
PageState
Next Recommended Reading
Overview of Service Application Architecture in SharePoint 2013