Usage
m365 spo listitem retentionlabel ensure [options]
Description
Apply a retention label to a list item
Options
| Option |
Description |
-u, --webUrl <webUrl> |
The url of the web. |
--listId [listId] |
ID of the list where the item should be labelled. Specify either listTitle, listId or listUrl. |
--listTitle [listTitle] |
Title of the list where the item should be labelled. Specify either listTitle, listId or listUrl. |
--listUrl [listUrl] |
Server- or site-relative URL of the list where the item should be labelled. Specify either listTitle, listId or listUrl. |
--listItemId <listItemId> |
ID of the list item on which the label should be applied. |
-n, --name [name] |
Name of the retention label to apply to the list item. Specify either name or id. |
-i, --id [id] |
Id of the retention label to apply to the list item. Specify either name or id. |
Examples
Apply the label some label to a list item
m365 spo listitem retentionlabel set --webUrl 'https://contoso.sharepoint.com/sites/sales' --listTitle 'some list' --listItemId 1 --name 'Some retention label'
More information
This command can be implemented with shared code in a util, so that new commands spo file retentionlabel add and spo folder retentionlabel add can profit from the same code.
CSOM has this set of functions with which to apply retentionlabel:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.listitem.setcompliancetag?view=sharepoint-csom
These functions are available in the Rest API as well:
<FunctionImport Name="SetComplianceTag" IsBindable="true">
<Parameter Name="this" Type="SP.Workflow.SPWorkflowTask"/>
<Parameter Name="complianceTag" Type="Edm.String"/>
<Parameter Name="isTagPolicyHold" Type="Edm.Boolean" Nullable="false"/>
<Parameter Name="isTagPolicyRecord" Type="Edm.Boolean" Nullable="false"/>
<Parameter Name="isEventBasedTag" Type="Edm.Boolean" Nullable="false"/>
<Parameter Name="isTagSuperLock" Type="Edm.Boolean" Nullable="false"/>
<Parameter Name="isUnlockedAsDefault" Type="Edm.Boolean" Nullable="false"/>
</FunctionImport>
The SharePoint User Interface executes this as follows:
POST to https://contoso.sharepoint.com/sites/project-x/_api/web/GetList(@a1)/items(@a2)/SetComplianceTag()?@a1='/sites/project-x/Lists/some-list'&@a2='1'
Payload:
{
"complianceTag":"Test Recordlabel",
"isTagPolicyHold":true,
"isTagPolicyRecord":true,
"isEventBasedTag":false,
"isTagSuperLock":false,
"isUnlockedAsDefault":false
}
The values for the payload are determined based on the label that's chosen.
Usage
m365 spo listitem retentionlabel ensure [options]
Description
Apply a retention label to a list item
Options
-u, --webUrl <webUrl>--listId [listId]listTitle,listIdorlistUrl.--listTitle [listTitle]listTitle,listIdorlistUrl.--listUrl [listUrl]listTitle,listIdorlistUrl.--listItemId <listItemId>-n, --name [name]nameorid.-i, --id [id]nameorid.Examples
Apply the label some label to a list item
More information
CSOM has this set of functions with which to apply retentionlabel:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.listitem.setcompliancetag?view=sharepoint-csom
These functions are available in the Rest API as well:
The SharePoint User Interface executes this as follows:
POST to https://contoso.sharepoint.com/sites/project-x/_api/web/GetList(@a1)/items(@a2)/SetComplianceTag()?@a1='/sites/project-x/Lists/some-list'&@a2='1'
Payload:
{ "complianceTag":"Test Recordlabel", "isTagPolicyHold":true, "isTagPolicyRecord":true, "isEventBasedTag":false, "isTagSuperLock":false, "isUnlockedAsDefault":false }The values for the payload are determined based on the label that's chosen.