@pnp/sp/web - tenant properties¶
You can set, read, and remove tenant properties using the methods shown below:
setStorageEntity¶
This method MUST be called in the context of the app catalog web or you will get an access denied message.
import { Web } from "@pnp/sp/webs";
const w = Web("https://tenant.sharepoint.com/sites/appcatalog/");
// specify required key and value
await w.setStorageEntity("Test1", "Value 1");
// specify optional description and comments
await w.setStorageEntity("Test2", "Value 2", "description", "comments");
getStorageEntity¶
This method can be used from any web to retrieve values previously set.
import { sp, IStorageEntity } from "@pnp/sp/presets/all";
const prop: IStorageEntity = await sp.web.getStorageEntity("Test1");
console.log(prop.Value);
removeStorageEntity¶
This method MUST be called in the context of the app catalog web or you will get an access denied message.
import { Web } from "@pnp/sp/webs";
const w = Web("https://tenant.sharepoint.com/sites/appcatalog/");
await w.removeStorageEntity("Test1");