create_sp_list() allows the creation of a SharePoint list for a site. See:
https://learn.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http
update_sp_list() allows the modification of the list display name and
description.
delete_sp_list() deletes an existing list and requires user confirmation by
default.
Notes on creating a SharePoint list:
Dashes (`"-"“) in list names are removed from the list name but retained in the list display name.
Column names longer than 32 characters (counting each space or special character as 7) are an error for a list (but not a document library), since SharePoint cuts them without an error. A display name longer than 255 characters (the limit on the column settings page) is a warning.
Calculated columns are added after the list is created since formulas may reference other columns.
Column validation is applied with the SharePoint REST API after the list is created since the Graph API doesn't support it.
A
"Title"column incolumnsordefinitionupdates the default"Title"column of a"genericList"list (combined withtitle_definition) or a"documentLibrary"library instead of adding a new column.Views in
definitionare created with the SharePoint REST API after the columns are created. A view titled"All Items"updates the default view of a"genericList"list and a view titled"All Documents"updates the default view of a"documentLibrary"library.Folders in
definitionare created after the views for a"documentLibrary"library. Usecreate_sp_drive()to create a document library and return thems_driveobject.
Notes on updating a SharePoint list:
The
"Title"column type is always a "text" type column and can't be changed.
Usage
create_sp_list(
list_name = NULL,
...,
description = NULL,
columns = NULL,
template = NULL,
content_types = NULL,
hidden = NULL,
title_definition = list(required = FALSE),
definition = NULL,
site_url = NULL,
site = NULL,
call = caller_env()
)
update_sp_list(
list_name = NULL,
list_id = NULL,
sp_list = NULL,
display_name = NULL,
description = NULL,
...,
site_url = NULL,
site = NULL,
drive_name = NULL,
drive_id = NULL,
drive = NULL,
call = caller_env()
)
delete_sp_list(
list_name = NULL,
list_id = NULL,
sp_list = NULL,
confirm = TRUE,
...,
site_url = NULL,
site = NULL,
drive_name = NULL,
drive_id = NULL,
drive = NULL,
call = caller_env()
)Arguments
- list_name
List name used as
displayNameproperty. Required unlessdefinitionis supplied.- ...
Additional parameters passed to
get_sp_site()orMicrosoft365R::get_sharepoint_site().- description
Optional description.
- columns
Optional. Use
create_column_definition()to create a single column definition orcreate_column_definition_list()to create a list of column definitions.custommetadata is dropped. Asp_list_definitionobject is used asdefinition.- template
Optional list template (Graph listInfo property
template). Defaults to"genericList".- content_types
Optional. Set
TRUEforcontentTypesEnabledto be enabled.Optional. Set
TRUEfor list to be hidden.- title_definition
Named list used to update the column definition of the default
"Title"column created when using the"genericList"template. By default, makes Title column optional.- definition
Optional. A list definition from
read_sp_list_yaml()or a path to a YAML file. The definitiondisplayName,description,columns, andlistsettings (template,hidden, andcontentTypesEnabled) are used unless the matching argument is supplied. Read-only list properties (e.g.id) and column ids are ignored.definitioncan't be combined withcolumns. Views in the definition are also created (seelist_sp_list_views()), and so are folders for a document library.- site_url
A SharePoint site URL in the format "https://[tenant name].sharepoint.com/sites/[site name]". Any SharePoint item or document URL can also be parsed to build a site URL using the tenant and site name included in the URL.
- site
A
ms_siteobject. Ifsiteis supplied,site_url,site_name, andsite_idare ignored.- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.- list_id
List ID for list to update or delete.
- sp_list
A
Microsoft365R::ms_listobject.- display_name
Display name to replace existing display name. Used by
update_sp_list().- drive_name, drive_id
SharePoint Drive name or ID passed to
get_drivemethod for SharePoint site object.- drive
A
ms_driveobject. Ifdriveis supplied,drive_nameanddrive_idare ignored.- confirm
If
TRUE, confirm deletion of list before proceeding.