Get current publishing page id in custom action using JavaScript


Pierre Binamé

Dear all,

I was trying to add a custom action on the table “WikiPageTab”. In the command of my button that I added to the page I used the tag “{ItemId}” to get the id of the current page in my JavaScript code.

But bad surprise ItemId was null and I needed it in my JavaScript to do my stuff. So the question was how retrieve the page id of the current page????

After searching the answer is to use the global SharePoint JavaScript object “_spPageContextInfo”. In this very useful object you have a variable called “pageItemId”.

So in your JavaScript to get the current page id you have to write this: _spPageContextInfo.pageItemId

Here all useful properties of the _spPageContextInfo object:

PropertiesSample value
alertEnabledtrue
allowSilverlightPrompt“True”
clientServerTimeDelta-164
crossDomainPhotosEnabledfalse
currentCultureName“fr-FR”
currentLanguage1036
currentUICultureName“fr-FR”
layoutsUrl“_layouts/15”
pageItemId2
pageListId“{f84e836b-869d-40d1-a8d1-9653b72e8873}”
pagePersonalizationScope

View original post 49 more words