Skip to content

New command: spo listitem batch set #4549

@waldekmastykarz

Description

@waldekmastykarz

Usage

m365 spo listitem batch set [options]

Description

Updates list items in a batch

Options

-p, --filePath <filePath>
The absolute or relative path to a flat file containing the list items to update.

-s, --systemUpdate
Update the item without updating the modified date and modified by fields

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

-l, --listId [listId]
ID of the list. Specify either listTitle, listId or listUrl, but not multiple.

-t, --listTitle [listTitle]
Title of the list. Specify either listTitle, listId or listUrl, but not multiple.

--listUrl [listUrl]
Server- or site-relative URL of the list. Specify either listTitle, listId or listUrl, but not multiple.

Examples

Add a batch of items to a list retrieved by title in a specific site

m365 spo listitem batch set --filePath "C:\Path\To\Csv\CsvFile.csv" --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle "Demo List"

Default properties

No response

Additional Info

  • CSV file must contain the ID column which is used as a reference for the item to update
  • If any of the requests inside a batch fails, CLI keeps track of it and continues silently
  • If the whole batch fails, CLI stops with an error
  • At the end of execution, CLI shows a list of failed requests (not batches!) in the following format (sent to stderr):
Failed requests:
- https://contoso.sharepoint.com/Lists/MyList/1.000
- https://contoso.sharepoint.com/Lists/MyList/10.000
- ...

The ability to specify key column in the CSV file will be added as an enhancement after the basic functionality has been shipped.

Documentation of the data format for complex types (date, person, lookup, taxonomy term) will be taken separately and included in a central place in the docs so that we can reference it from all commands that require it (listitem add, -set, batch add, etc).

Discussed in #4548

Originally posted by bGlasson February 20, 2023
Found m365 CLI today and it looks super useful.

Problem I need to solve right now is updating 10'000s of list items (metadata on files in library, so deleting then batch-adding is not an option).

PnP.PowerShell batching isn't an option in my environment, this would be an ideal solution.... and a (seemingly?) natural extension.

Couldn't see any discussion on this so far.... hoping I've missed some easy way to achieve it already 😅

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions