Skip to content

Commit

Permalink
Adds command 'spo contenttype sync'. Closes #5551
Browse files Browse the repository at this point in the history
  • Loading branch information
MathijsVerbeeck authored and martinlingstuyl committed Apr 2, 2024
1 parent 72886a7 commit 03c2237
Show file tree
Hide file tree
Showing 5 changed files with 637 additions and 0 deletions.
144 changes: 144 additions & 0 deletions docs/docs/cmd/spo/contenttype/contenttype-sync.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# spo contenttype sync

Adds a published content type from the content type hub to a site or syncs its latest changes.

## Usage

```sh
m365 spo contenttype sync [options]
```

## Options

```md definition-list
`-u, --webUrl <webUrl>`
: The site to sync the Content Type to.

`-i, --id [id]`
: The Id of the published Content Type to sync from the Content Type Hub. Specify either `id` or `name`.

`-n, --name [name]`
: The name of the published Content Type to sync from the Content Type Hub. Specify either `id` or `name`.

`--listTitle [listTitle]`
: Title of the list. Specify either `listTitle`, `listId` or `listUrl`. Omit to sync as a site content type.

`--listId [listId]`
: ID of the list. Specify either `listTitle`, `listId` or `listUrl`. Omit to sync as a site content type.

`--listUrl [listUrl]`
: Server- or site-relative URL of the list. Specify either `listTitle`, `listId` or `listUrl`. Omit to sync as a site content type.
```

<Global />

## Examples

Syncs a given published content type from the hub to the specified site.

```sh
m365 spo contenttype sync —webUrl https://contoso.sharepoint.com/sites/sales --id 0x01007926A45D687BA842B947286090B8F67D
```

Syncs a given published content type from the hub to the specified site and adds it to the specified list.

```sh
m365 spo contenttype sync —webUrl https://contoso.sharepoint.com/sites/sales --id 0x01007926A45D687BA842B947286090B8F67D --listTitle Contacts
```

## Response

:::info

This command will only return a response if the content type is added to the site initially. When syncing the content type, no response is returned.

:::

<Tabs>
<TabItem value="JSON">

```json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#contentType",
"@odata.type": "#microsoft.graph.contentType",
"@odata.etag": "\"2\"",
"id": "0x0101003D510887202C894AB7CD88CCE011519D",
"isBuiltIn": false,
"description": "",
"group": "Custom Content Types",
"hidden": false,
"name": "Dummy",
"parentId": "0x0101",
"readOnly": true,
"sealed": false,
"base": {
"id": "0x0101",
"description": "Create a new document.",
"group": "Document Content Types",
"hidden": false,
"name": "Document",
"readOnly": false,
"sealed": false
}
}
```

</TabItem>
<TabItem value="Text">

```text
@odata.context: https://graph.microsoft.com/v1.0/$metadata#contentType
@odata.etag : "2"
@odata.type : #microsoft.graph.contentType
base : {"id":"0x0101","description":"Create a new document.","group":"Document Content Types","hidden":false,"name":"Document","readOnly":false,"sealed":false}
description :
group : Custom Content Types
hidden : false
id : 0x01010004448644DB17414A9F1174B4FBFD9AC1
isBuiltIn : false
name : Dummy
parentId : 0x0101
readOnly : true
sealed : false
```

</TabItem>
<TabItem value="CSV">

```csv
@odata.context,@odata.type,@odata.etag,id,isBuiltIn,description,group,hidden,name,parentId,readOnly,sealed
https://graph.microsoft.com/v1.0/$metadata#contentType,#microsoft.graph.contentType,"""2""",0x010100F4ACBE99F2DBDE42B0487A561A40F9EE,,,Custom Content Types,,Dummy,0x0101,1,
```

</TabItem>
<TabItem value="Markdown">

```md
# spo contenttype sync --webUrl "https://contoso.sharepoint.com/sites/project-x" --name "Dummy"

Date: 13/03/2024

## Dummy (0x010100F4ACBE99F2DBDE42B0487A561A40F9EE)

Property | Value
---------|-------
@odata.context | https://graph.microsoft.com/v1.0/$metadata#contentType
@odata.type | #microsoft.graph.contentType
@odata.etag | "2"
id | 0x010100F4ACBE99F2DBDE42B0487A561A40F9EE
isBuiltIn | false
description |
group | Custom Content Types
hidden | false
name | Dummy 5
parentId | 0x0101
readOnly | true
sealed | false
```

</TabItem>
</Tabs>
5 changes: 5 additions & 0 deletions docs/src/config/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,11 @@ const sidebars: SidebarsConfig = {
label: 'contenttype set',
id: 'cmd/spo/contenttype/contenttype-set'
},
{
type: 'doc',
label: 'contenttype sync',
id: 'cmd/spo/contenttype/contenttype-sync'
},
{
type: 'doc',
label: 'contenttype field remove',
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 @@ -38,6 +38,7 @@ export default {
CONTENTTYPE_LIST: `${prefix} contenttype list`,
CONTENTTYPE_REMOVE: `${prefix} contenttype remove`,
CONTENTTYPE_SET: `${prefix} contenttype set`,
CONTENTTYPE_SYNC: `${prefix} contenttype sync`,
CONTENTTYPEHUB_GET: `${prefix} contenttypehub get`,
CUSTOMACTION_ADD: `${prefix} customaction add`,
CUSTOMACTION_CLEAR: `${prefix} customaction clear`,
Expand Down
Loading

0 comments on commit 03c2237

Please sign in to comment.