|
import { spfi, SPBrowser, IUserCustomActionInfo } from "@pnp/sp/presets/all"; |
|
|
|
const sp = spfi().using(SPBrowser({ baseUrl: (window as any)._spPageContextInfo.webAbsoluteUrl })); |
|
|
|
(async () => { |
|
console.clear(); |
|
|
|
const { Title } = await sp.web.select("Title")() |
|
console.log(`Web title: ${Title}`); |
|
|
|
let ucaList = await sp.web.userCustomActions.filter(`Title eq 'UCA Title'`).select("*")() |
|
console.log(`User Custom Actions (before):`, { ucaList }); |
|
|
|
const uca = sp.web.userCustomActions.getById(ucaList[0].Id); |
|
const newProperties = { |
|
ClientSideComponentProperties: `${JSON.stringify({ testMessage: "App Customiser Message"})}` |
|
}; |
|
const updateResponse = await uca.update(newProperties as unknown as IUserCustomActionInfo); |
|
console.log(`Update UCA response:`, { updateResponse }); |
|
|
|
ucaList = await sp.web.userCustomActions.filter(`Title eq 'UCA Title'`).select("*")() |
|
console.log(`User Custom Actions (after):`, { ucaList }); |
|
|
|
})().catch(console.error) |
|
|
|
/** Sample User Custom Action |
|
{ |
|
"odata.type": "SP.UserCustomAction", |
|
"odata.id": "https://tenant.sharepoint.com/sites/sitename/_api/Web/UserCustomActions(guid'878f3724-81b5-4676-936d-73124b0a0312')", |
|
"odata.editLink": "Web/UserCustomActions(guid'878f3724-81b5-4676-936d-73124b0a0312')", |
|
"ClientSideComponentId": "98c3b0a1-a693-43d7-92e4-ced2638f11f7", |
|
"ClientSideComponentProperties": "{\"testMessage\":\"Test message\"}", |
|
"CommandUIExtension": null, |
|
"Description": null, |
|
"Group": null, |
|
"HostProperties": "", |
|
"Id": "878f3724-81b5-4676-936d-73124b0a0312", |
|
"ImageUrl": null, |
|
"Location": "ClientSideExtension.ApplicationCustomizer", |
|
"Name": "{878f3724-81b5-4676-936d-73124b0a0312}", |
|
"RegistrationId": null, |
|
"RegistrationType": 0, |
|
"Rights": { |
|
"High": "0", |
|
"Low": "0" |
|
}, |
|
"Scope": 3, |
|
"ScriptBlock": null, |
|
"ScriptSrc": null, |
|
"Sequence": 65536, |
|
"Title": "App Customiser Title", |
|
"Url": null, |
|
"VersionOfUserCustomAction": "1.0.16.0" |
|
} |
|
*/ |