Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Global from '../../_global.mdx';

# spo applicationcustomizer add

Add an application customizer to a site
Add an Application Customizer to a site

## Usage

Expand All @@ -14,29 +14,32 @@ m365 spo applicationcustomizer add [options]

```md definition-list
`-t, --title <title>`
: The title of the application customizer.
: The title of the Application Customizer.

`-u, --webUrl <webUrl>`
: URL of the site.

`-i, --clientSideComponentId <clientSideComponentId>`
: Client-side component ID of the application customizer (GUID).
: Client-side component ID of the Application Customizer (GUID).

`--description [description]`
: Description of the application customizer.
: Description of the Application Customizer.

`--clientSideComponentProperties [clientSideComponentProperties]`
: JSON string with application customizer properties.
: JSON string with Application Customizer properties.

`--hostProperties [hostProperties]`
: Set the host properties of the Application Customizer.

`-s, --scope [scope]`
: Scope of the application customizer. Allowed values: `Site`, `Web`. Defaults to `Site`.
: Scope of the Application Customizer. Allowed values: `Site`, `Web`. Defaults to `Site`.
```

<Global />

## Remarks

Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for command options that have JSON, XML or JavaScript values because the command shell treats quotes differently. For example, this is how an application customizer can be created from the Windows cmd.exe:
Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for command options that have JSON, XML or JavaScript values because the command shell treats quotes differently. For example, this is how an Application Customizer can be created from the Windows cmd.exe:

```sh
m365 spo applicationcustomizer add --webUrl https://contoso.sharepoint.com/sites/test --title "YourAppCustomizer" --clientSideComponentId b41916e7-e69d-467f-b37f-ff8ecf8f99f2 --clientSideComponentProperties '{\"testMessage\":\"Test message\"}'
Expand All @@ -46,21 +49,21 @@ Note, how the clientSideComponentProperties option has escaped double quotes `'{

:::warning[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](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.
When using the `--clientSideComponentProperties` or `--hostProperties` options it's possible to enter a JSON string. In PowerShell 5 to 7.2 [specific escaping rules](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.

:::

This command can be used for configuring an application customizer on a specific site. To configure an application customizer tenant-wide, view our dedicated [spo tenant applicationcustomizer add](../tenant/tenant-applicationcustomizer-add.mdx) command.
This command can be used for configuring an Application Customizer on a specific site. To configure an Application Customizer tenant-wide, view our dedicated [spo tenant applicationcustomizer add](../tenant/tenant-applicationcustomizer-add.mdx) command.

## Examples

Adds an application customizer to the sales site.
Adds an Application Customizer to the sales site.

```sh
m365 spo applicationcustomizer add --title 'Some customizer' --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --webUrl https://contoso.sharepoint.com/sites/sales
```

Adds an application customizer to the sales site with some properties.
Adds an Application Customizer to the sales site with some properties.

```sh
m365 spo applicationcustomizer add --title 'Some customizer' --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --clientSideComponentProperties '{ "someProperty": "Some value" }' --webUrl https://contoso.sharepoint.com/sites/sales --scope 'Site'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ m365 spo applicationcustomizer set [options]
: The new title of the Application Customizer.

`--description [description]`
: Description of the application customizer. Specify an empty string to clear.
: Description of the Application Customizer. Specify an empty string to clear.

`-p, --clientSideComponentProperties [clientSideComponentProperties]`
: The Client Side Component properties of the Application Customizer.

`--hostProperties [hostProperties]`
: Set the host properties for the Application Customizer. Set to an empty string to clear the value.

`-s, --scope [scope]`
: The scope where to lookup the Application Customizer. Allowed values: `Site`, `Web`, and `All`. Defaults to `All`.
```
Expand All @@ -42,7 +45,7 @@ m365 spo applicationcustomizer set [options]

## Remarks

Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for clientSideComponentProperties option that has JSON value because the command shell treats quotes differently. For example, this is how Application Customizer can be updated from the Windows cmd.exe:
Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for `clientSideComponentProperties` and `hostProperties` options that have JSON value because the command shell treats quotes differently. For example, this is how Application Customizer can be updated from the Windows cmd.exe:

```sh
m365 spo applicationcustomizer set --webUrl https://contoso.sharepoint.com/sites/sales --id b41916e7-e69d-467f-b37f-ff8ecf8f99f2 --newTitle "Some customizer" --clientSideComponentProperties '{\"testMessage\":\"Test message\"}'
Expand All @@ -52,21 +55,21 @@ Note, how the clientSideComponentProperties option (--clientSideComponentPropert

:::warning[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](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.
When using the `--clientSideComponentProperties` or `--hostProperties` options it's possible to enter a JSON string. In PowerShell 5 to 7.2 [specific escaping rules](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.

:::

This command can be used for updating an application customizer on a specific site. To update an application customizer that's installed tenant-wide, view our dedicated [spo tenant applicationcustomizer set](../tenant/tenant-applicationcustomizer-set.mdx) command.
This command can be used for updating an Application Customizer on a specific site. To update an Application Customizer that's installed tenant-wide, view our dedicated [spo tenant applicationcustomizer set](../tenant/tenant-applicationcustomizer-set.mdx) command.

## Examples

Updates the title of an application customizer on the sales site.
Updates the title of an Application Customizer on the sales site.

```sh
m365 spo applicationcustomizer set --id 058140e3-0e37-44fc-a1d3-79c487d371a3 --newTitle "Some customizer" --webUrl https://contoso.sharepoint.com/sites/sales
```

Updates the properties of an application customizer on the sales site.
Updates the properties of an Application Customizer on the sales site.

```sh
m365 spo applicationcustomizer set --id 058140e3-0e37-44fc-a1d3-79c487d371a3 --clientSideComponentProperties '{ "testMessage": "Test message" }' --webUrl https://contoso.sharepoint.com/sites/sales
Expand Down
23 changes: 13 additions & 10 deletions docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Global from '../../_global.mdx';

# spo tenant applicationcustomizer add

Add an application customizer as a tenant-wide extension
Add an Application Customizer as a tenant-wide extension

## Usage

Expand All @@ -17,13 +17,16 @@ m365 spo tenant applicationcustomizer add [options]
: The title of the Application Customizer.

`-i, --clientSideComponentId <clientSideComponentId>`
: The Client Side Component Id (GUID) of the application customizer.
: The Client Side Component Id (GUID) of the Application Customizer.

`-p, --clientSideComponentProperties [clientSideComponentProperties]`
: The Client Side Component properties of the application customizer.
: The Client Side Component properties of the Application Customizer.

`--hostProperties [hostProperties]`
: Set the host properties of the Application Customizer.

`-w, --webTemplate [webTemplate]`
: Optionally add a web template (e.g. STS#3, SITEPAGEPUBLISHING#0, etc) as a filter for what kind of sites the application customizer is registered on.
: Optionally add a web template (e.g. STS#3, SITEPAGEPUBLISHING#0, etc) as a filter for what kind of sites the Application Customizer is registered on.
```

<Global />
Expand All @@ -40,7 +43,7 @@ Note, how the clientSideComponentProperties option has escaped double quotes `'{

:::warning[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](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.
When using the `--clientSideComponentProperties` or `--hostProperties` options it's possible to enter a JSON string. In PowerShell 5 to 7.2 [specific escaping rules](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.

:::

Expand All @@ -50,20 +53,20 @@ To use this command, you need to be a SharePoint Admin.

:::

This command can be used for configuring a tenant-wide application customizer. To configure an application customizer on a specific site, view our dedicated [spo applicationcustomizer add](../applicationcustomizer/applicationcustomizer-add.mdx) command.
This command can be used for configuring a tenant-wide Application Customizer. To configure an Application Customizer on a specific site, view our dedicated [spo applicationcustomizer add](../applicationcustomizer/applicationcustomizer-add.mdx) command.

## Examples

Adds an application customizer that's deployed tenant wide
Adds an Application Customizer that's deployed tenant wide

```sh
m365 spo tenant applicationcustomizer add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc
m365 spo tenant applicationcustomizer add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc
```

Adds an application customizer that is configured for all communication sites.
Adds an Application Customizer that is configured for all communication sites.

```sh
m365 spo tenant applicationcustomizer add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --webTemplate "SITEPAGEPUBLISHING#0"
m365 spo tenant applicationcustomizer add --title "Some customizer" --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --webTemplate "SITEPAGEPUBLISHING#0"
```

## Response
Expand Down
11 changes: 7 additions & 4 deletions docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,28 @@ m365 spo tenant applicationcustomizer set [options]
`-p, --clientSideComponentProperties [clientSideComponentProperties]`
: The Client Side Component properties of the Application Customizer.

`--hostProperties [hostProperties]`
: Set the host properties of the Application Customizer. Set to an empty string to clear the value.

`-w, --webTemplate [webTemplate]`
: Optionally add a web template (e.g. STS#3, SITEPAGEPUBLISHING#0, etc) as a filter for what kind of sites the application customizer is registered on.
: Optionally add a web template (e.g. STS#3, SITEPAGEPUBLISHING#0, etc) as a filter for what kind of sites the Application Customizer is registered on.
```

<Global />

## Remarks

Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for clientSideComponentProperties option that has JSON value because the command shell treats quotes differently. For example, this is how Application Customizer can be updated from the Windows cmd.exe:
Running this command from the Windows Command Shell (cmd.exe) or PowerShell for Windows OS XP, 7, 8, 8.1 without bash installed might require additional formatting for `clientSideComponentProperties` and `hostProperties` options that have JSON values because the command shell treats quotes differently. For example, this is how Application Customizer can be updated from the Windows cmd.exe:

```sh
m365 spo tenant applicationcustomizer set --id 3 --clientSideComponentProperties '{\"someProperty\":\"Some value\"}'
```

Note, how the clientSideComponentProperties option (--clientSideComponentProperties) has escaped double quotes `'{\"someProperty\":\"Some value\"}'` compared to execution from bash `'{"someProperty": "Some value"}'`.
Note, how the `--clientSideComponentProperties` option has escaped double quotes `'{\"someProperty\":\"Some value\"}'` compared to execution from bash `'{"someProperty": "Some value"}'`.

:::warning[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](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.
When using the `--clientSideComponentProperties` or `--hostProperties` options it's possible to enter a JSON string. In PowerShell 5 to 7.2 [specific escaping rules](./../../../user-guide/using-cli.mdx#escaping-double-quotes-in-powershell) apply due to an issue. Remember that you can also use [file tokens](./../../../user-guide/using-cli.mdx#passing-complex-content-into-cli-options) instead.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,36 +95,66 @@ describe(commands.APPLICATIONCUSTOMIZER_ADD, () => {
});

it('adds the application customizer to a specific site without specifying clientSideComponentProperties', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === 'https://contoso.sharepoint.com/_api/Web/UserCustomActions'
&& opts.data['Location'] === 'ClientSideExtension.ApplicationCustomizer'
&& opts.data['ClientSideComponentId'] === clientSideComponentId
&& opts.data['Name'] === title
&& opts.data['ClientSideComponentProperties'] === undefined) {
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === 'https://contoso.sharepoint.com/_api/Web/UserCustomActions') {
return;
}

throw customActionError;
});

await command.action(logger, { options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, scope: 'Web' } });
assert.deepStrictEqual(postStub.firstCall.args[0].data, {
Title: title,
Name: title,
Description: undefined,
Location: 'ClientSideExtension.ApplicationCustomizer',
ClientSideComponentId: clientSideComponentId,
HostProperties: ''
});
assert(loggerLogToStderrSpy.notCalled);
});

it('adds the application customizer to a specific site while specifying clientSideComponentProperties', async () => {
sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === 'https://contoso.sharepoint.com/_api/Site/UserCustomActions'
&& opts.data['Location'] === 'ClientSideExtension.ApplicationCustomizer'
&& opts.data['ClientSideComponentId'] === clientSideComponentId
&& opts.data['ClientSideComponentProperties'] === clientSideComponentProperties
&& opts.data['Name'] === title) {
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === 'https://contoso.sharepoint.com/_api/Site/UserCustomActions') {
return customActionAddResponse;
}

throw customActionError;
});

await command.action(logger, { options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, description: description, clientSideComponentProperties: clientSideComponentProperties, verbose: true } });
assert.deepStrictEqual(postStub.firstCall.args[0].data, {
Title: title,
Name: title,
Description: description,
Location: 'ClientSideExtension.ApplicationCustomizer',
ClientSideComponentId: clientSideComponentId,
ClientSideComponentProperties: clientSideComponentProperties,
HostProperties: ''
});
assert(loggerLogToStderrSpy.called);
});

it('adds the application customizer to a specific site while specifying hostProperties', async () => {
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
if (opts.url === 'https://contoso.sharepoint.com/_api/Site/UserCustomActions') {
return customActionAddResponse;
}

throw customActionError;
});

await command.action(logger, { options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, description: description, hostProperties: clientSideComponentProperties, verbose: true } });
assert.deepStrictEqual(postStub.firstCall.args[0].data, {
Title: title,
Name: title,
Description: description,
Location: 'ClientSideExtension.ApplicationCustomizer',
ClientSideComponentId: clientSideComponentId,
HostProperties: clientSideComponentProperties
});
assert(loggerLogToStderrSpy.called);
});

Expand All @@ -148,8 +178,13 @@ describe(commands.APPLICATIONCUSTOMIZER_ADD, () => {
assert.notStrictEqual(actual, true);
});

it('fails validation if the hostProperties option is not a valid json string', async () => {
const actual = await command.validate({ options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, hostProperties: 'invalid json string' } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('passes validation if all options are passed', async () => {
const actual = await command.validate({ options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, clientSideComponentProperties: clientSideComponentProperties, scope: 'Site' } }, commandInfo);
const actual = await command.validate({ options: { webUrl: webUrl, title: title, clientSideComponentId: clientSideComponentId, clientSideComponentProperties: clientSideComponentProperties, hostProperties: clientSideComponentProperties, scope: 'Site' } }, commandInfo);
assert.strictEqual(actual, true);
});
});
Loading