Skip to content

Instantly share code, notes, and snippets.

@phillipharding
Last active January 9, 2026 10:58
Show Gist options
  • Select an option

  • Save phillipharding/a903d2593b0d888514d9a125fa8a06bd to your computer and use it in GitHub Desktop.

Select an option

Save phillipharding/a903d2593b0d888514d9a125fa8a06bd to your computer and use it in GitHub Desktop.
Retrieves and Updates a SharePoint App Customiser User Custom Action
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"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment