Created
November 30, 2021 07:19
-
-
Save ktskumar/0e74e5a4a54ba969e4efbed556ddbdc2 to your computer and use it in GitHub Desktop.
Change Item Level permission for SitePages Library
This file contains 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
//Update the WriteSecurity to change the item level permissions | |
//Set the Edit property to Create items and edit items that were created by the user | |
// 1 - Create and edit all items | |
// 2 - Create items and edit items that were created by the user | |
// 3 - None | |
import { sp, Web } from "@pnp/sp/presets/all"; | |
(async () => { | |
let web1 = await Web("https://contoso.sharepoint.com/sites/sitename"); | |
const list = await web1.lists.getByTitle("Site Pages").select('Title,ReadSecurity,WriteSecurity').get() | |
console.log("Before Update: " + list.Title); | |
console.log("************************************"); | |
console.log('Read Security: ' + list.ReadSecurity); | |
console.log('Write Security: ' + list.WriteSecurity); | |
console.log("\n"); | |
const updateProperties = { | |
WriteSecurity: 2 | |
}; | |
await web1.lists.getByTitle("Site Pages").update(updateProperties).then(async (l: any) => { | |
// get the updated WriteSecurity | |
const r = await l.list.select("Title", "Description", "ReadSecurity", "WriteSecurity")(); | |
console.log("After Update: " + r.Title); | |
console.log("************************************") | |
console.log('Read Security: ' + r.ReadSecurity); | |
console.log('Write Security: ' + r.WriteSecurity); | |
}); | |
})().catch(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment