Skip to content

Commit

Permalink
Adds command 'spo list defaultValue set'. Closes #6503
Browse files Browse the repository at this point in the history
  • Loading branch information
milanholemans committed Jan 17, 2025
1 parent f5e6f85 commit 9b2341e
Show file tree
Hide file tree
Showing 5 changed files with 784 additions and 0 deletions.
112 changes: 112 additions & 0 deletions docs/docs/cmd/spo/list/list-defaultvalue-set.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import Global from '/docs/cmd/_global.mdx';

# spo list defaultvalue set

Sets default column values for a specific document library

## Usage

```sh
m365 spo list defaultvalue set [options]
```

## Options

```md definition-list
`-u, --webUrl <webUrl>`
: URL of the site where the list is located.

`-i, --listId [listId]`
: ID of the list. Specify either `listTitle`, `listId`, or `listUrl`.

`-t, --listTitle [listTitle]`
: Title of the list. Specify either `listTitle`, `listId`, or `listUrl`.

`--listUrl [listUrl]`
: Server- or site-relative URL of the list. Specify either `listTitle`, `listId`, or `listUrl`.

`--fieldName <fieldName>`
: Internal name of the field.

`--fieldValue <fieldValue>`
: Default value of the field.

`--folderUrl [folderUrl]`
: Set the value to a specific folder. By default, the root folder of the list is used.
```

<Global />

# Remarks

:::note

Due to limitations in SharePoint Online, setting default column values for folders with a `#` or `%` character in their path is not supported.

:::

## Examples

Set a default folder value on the root folder of a list for a text field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listTitle Logos --fieldName Company --fieldValue Contoso
```

Set a default folder value for a taxonomy field on a specific folder

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listTitle Logos --folderUrl "/sites/Marketing/Logos/Contoso" --fieldName Country --fieldValue "-1;#Belgium|442affc2-7fab-4f33-9590-330403a579c2"
```

Set a default folder value for a multi-taxonomy field on a specific folder

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listUrl /sites/marketing/Logos --folderUrl "/sites/Marketing/Logos/Contoso" --fieldName Countries --fieldValue "-1;#Belgium|442affc2-7fab-4f33-9590-330403a579c2;#-1;#France|14888324-5c48-46db-b748-215cbe24eb4c"
```

Set a default folder value for a date field to today

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listId 3540460d-cb6e-4bc5-8380-bc1844401ee3 --fieldName Published --fieldValue "[today]"
```

Set a default folder value for a date field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listTitle Logos --fieldName Published --fieldValue "2020-05-03T11:00:00Z"
```

Set a default folder value for a choice field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listUrl /sites/marketing/Logos --fieldName FileType --fieldValue Logo
```

Set a default folder value for a multi-choice field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listTitle Logos --fieldName FileTypes --fieldValue "Logo;#Brand"
```

Set a default folder value for a yes/no field using site-relative list URL

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listUrl /Logos --fieldName Active --fieldValue 1
```

Set a default folder value for a user field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listId 3540460d-cb6e-4bc5-8380-bc1844401ee3 --fieldName Responsible --fieldValue "1;#[email protected]"
```

Set a default folder value for a multi-user field

```sh
m365 spo list defaultvalue set --webUrl https://contoso.sharepoint.com/sites/Marketing --listId 3540460d-cb6e-4bc5-8380-bc1844401ee3 --fieldName Responsible --fieldValue "1;#[email protected];#2;#[email protected]"
```

## Response

The command won't return a response on success.
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,11 @@ const sidebars: SidebarsConfig = {
label: 'list defaultvalue list',
id: 'cmd/spo/list/list-defaultvalue-list'
},
{
type: 'doc',
label: 'list defaultvalue set',
id: 'cmd/spo/list/list-defaultvalue-set'
},
{
type: 'doc',
label: 'list retentionlabel ensure',
Expand Down
1 change: 1 addition & 0 deletions src/m365/spo/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default {
LIST_CONTENTTYPE_REMOVE: `${prefix} list contenttype remove`,
LIST_CONTENTTYPE_DEFAULT_SET: `${prefix} list contenttype default set`,
LIST_DEFAULTVALUE_LIST: `${prefix} list defaultvalue list`,
LIST_DEFAULTVALUE_SET: `${prefix} list defaultvalue set`,
LIST_GET: `${prefix} list get`,
LIST_LIST: `${prefix} list list`,
LIST_REMOVE: `${prefix} list remove`,
Expand Down
Loading

0 comments on commit 9b2341e

Please sign in to comment.