Skip to content

New command: spo commandset set #4338

@martinlingstuyl

Description

@martinlingstuyl

Usage

spo commandset set [options]

Description

Updates a ListView Command Set on a site.

Options

Option Description
-u, --webUrl <webUrl> The site to update the ListView Command Set on.
-t, --title [title] The title of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
-i, --id [id] The id of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
-c, --clientSideComponentId [clientSideComponentId] The Client Side Component Id (GUID) of the ListView Command Set to update. Specify either title, id or clientSideComponentId.
--newTitle [newTitle] The new title of the ListView Command Set.
-l, --listType [listType] The list or library type to register the Command Set on. Allowed values List or Library.
--clientSideComponentProperties [clientSideComponentProperties] The Client Side Component properties of the ListView Command Set.
-s, --scope [scope] The scope where to lookup the ListView Command Set: at site level or web level. Allowed values: Site, Web, All. Defaults to All.
--location [location] The location of the ListView Command Set. Allowed values ContextMenu, CommandBar or Both.

Examples

Updates the title and location of a ListView Command Set on the sales site.

m365 spo commandset  set --clientSideComponentId  799883f5-7962-4384-a10a-105adaec6ffc --newTitle "Some new title" --location Both --webUrl https://contoso.sharepoint.com/sites/sales --scope Site

Updates a ListView Command Set on the sales site with some properties.

m365 spo commandset set --title "Some customizer" --clientSideComponentProperties '{ "someProperty": "Some value" }' --webUrl https://contoso.sharepoint.com/sites/sales --scope Site

Remarks

Add the following notice (like on https://pnp.github.io/cli-microsoft365/cmd/spo/customaction/customaction-add/)

Escaping JSON in PowerShell When using the --clientSideComponentProperties option it's possible to enter a JSON string. In PowerShell 5 to 7.2 specific escaping rules apply due to an issue. Remember that you can also use file tokens instead.

Additional Info

While developing we want to reuse the getCustomActions and getCustomActionById functions of the spo util class.

  • If the found custom action is not an command set: throw an error.
  • If two or more command set custom actions are found: prompt the user to disambiguate.

We can use the shared code to only query the commandset customaction we want: with a location value of ClientSideExtension.ListViewCommandSet, ClientSideExtension.ListViewCommandSet.CommandBar or ClientSideExtension.ListViewCommandSet.ContextMenu based on the value that's used.

The listType value maps to --registrationId of the custom action. List maps to 100, Library maps to 101

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions