Last active
November 24, 2015 08:01
-
-
Save xsolon/d8497ac480aec59d9477 to your computer and use it in GitHub Desktop.
SharePoint JSOM: Check permissions of current page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _spPageContextInfo | |
| { | |
| webServerRelativeUrl : "/ProjectWeb", | |
| webLanguage : 1033, | |
| currentLanguage : 1033, | |
| webUIVersion : 4, | |
| pageListId : "{c1d7b89f-f07b-4e2e-b89c-76c315831d59}", | |
| pageItemId : 5, | |
| userId : 68, | |
| alertsEnabled : true, | |
| siteServerRelativeUrl : "/", | |
| allowSilverlightPrompt : "True" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){ | |
| var ctx = SP.ClientContext.get_current(); | |
| var web = ctx.get_web(); | |
| var list = web.get_lists().getById(_spPageContextInfo.pageListId); | |
| var li = list.getItemById(_spPageContextInfo.pageItemId); | |
| ctx.load(li, 'EffectiveBasePermissions'); | |
| ctx.executeQueryAsync(function(){ | |
| var perms = li.get_effectiveBasePermissions(); | |
| // PermissionKind values: https://msdn.microsoft.com/en-us/library/office/ee556747(v=office.14).aspx | |
| if (perms.has(SP.PermissionKind.editListItems)) { | |
| console.log('can edit'); | |
| } | |
| }, function onError(request, errorArgs){ | |
| console.log(errorArgs.get_message()); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment