| Title: | Read and Write from SharePoint Sites |
|---|---|
| Description: | A R package extending 'Microsoft365R' to make it easier to read, write, and work with SharePoint items, lists, and plans. |
| Authors: | Eli Pousson [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8280-1706>) |
| Maintainer: | Eli Pousson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-10-16 17:47:03 UTC |
| Source: | https://github.com/elipousson/sharepointr |
as_column_definition() validates a named list of Microsoft Graph
columnDefinition properties, such as a column read from a YAML file with
read_sp_list_yaml() or returned by create_column_definition().
A column definition must have a name and exactly one column type key
(e.g. text, choice, or dateTime) holding the properties for that type.
Property names must match the Graph API documentation. Unknown properties
and read-only properties (e.g. type) are errors. A column id is allowed
as a reference to an existing column but isn't used to match, create, or
update columns. A custom element is allowed and isn't validated, so it
can hold metadata used by other applications.
Formulas for calculated columns, default values, and validation have a
leading "=" added if missing. Unlike create_calculated_column(), the
formula isn't processed with glue::glue().
as_column_definition(x, ..., allow_custom = TRUE, call = caller_env())as_column_definition(x, ..., allow_custom = TRUE, call = caller_env())
x |
A named list of columnDefinition properties. |
... |
Must be empty. |
allow_custom |
If |
call |
The execution environment of a currently
running function, e.g. |
The validated column definition x with choices converted to a
character vector and formulas normalized.
read_sp_list_yaml() for the YAML format that uses these definitions.
as_column_definition( list( name = "Notes", displayName = "Project Notes", text = list(allowMultipleLines = TRUE) ) )as_column_definition( list( name = "Notes", displayName = "Project Notes", text = list(allowMultipleLines = TRUE) ) )
AzureR_config_ls() uses rappdirs::user_config_dir() and fs::dir_ls() to
list files from the AzureR configuration directory. AzureR_config_delete()
uses fs::file_delete() to remove the "graph_logins.json" configuration file
if needed. Use this function with caution but it may be an option to address
a "Unable to refresh token" error.
AzureR_config_ls(path = NULL, glob = "*.json") AzureR_config_delete(path = NULL, filename = "graph_logins.json")AzureR_config_ls(path = NULL, glob = "*.json") AzureR_config_delete(path = NULL, filename = "graph_logins.json")
path |
Path to configuration directory for AzureR package where the JSON
file for graph_logins is stored. If |
glob |
A wildcard aka globbing pattern (e.g. |
filename |
Filename to delete from configuration directory. Defaults to
"graph_logins.json". Set to |
For AzureR_config_ls(), a character vector of file paths
matching glob in the AzureR configuration directory. For
AzureR_config_delete(), invisibly returns the path to the deleted
file.
column_validation() creates a columnValidation definition for the
validation property of a column definition. A validation formula must
evaluate to TRUE for a value to be saved.
column_validation(formula, descriptions = NULL, default_language = "en-US")column_validation(formula, descriptions = NULL, default_language = "en-US")
formula |
Required. Validation formula. Reference columns with the
display name enclosed in square brackets, e.g. |
descriptions |
Optional message shown when validation fails. Either a
string (used for |
default_language |
Default BCP 47 language tag for |
The Graph API doesn't support creating or updating a list column with a
validation property, so create_sp_list_column() and
sync_sp_list() apply validation with the SharePoint REST API
instead. Validation isn't returned when reading list columns with the Graph
API, so it can't be compared to an existing column.
A named list formatted as a columnValidation resource.
columnValidation resource type
column_validation("=LEN([Project Code])=8", "Use an 8 character code.")column_validation("=LEN([Project Code])=8", "Use an 8 character code.")
compare_sp_list() compares a list definition (e.g. from a YAML file read
with read_sp_list_yaml()) with an existing SharePoint list and returns the
list settings, columns, and views to add, update, or delete, and the
folders to add to a document library.
sync_sp_list() applies those changes. By default, it only prints the
planned changes (dry_run = TRUE) and doesn't delete columns or views
(delete = FALSE).
compare_sp_list( definitions, sp_list = NULL, ..., views = TRUE, folders = TRUE, call = caller_env() ) sync_sp_list( definitions, sp_list = NULL, ..., dry_run = TRUE, delete = FALSE, allow_data_loss = FALSE, views = TRUE, folders = TRUE, call = caller_env() )compare_sp_list( definitions, sp_list = NULL, ..., views = TRUE, folders = TRUE, call = caller_env() ) sync_sp_list( definitions, sp_list = NULL, ..., dry_run = TRUE, delete = FALSE, allow_data_loss = FALSE, views = TRUE, folders = TRUE, call = caller_env() )
definitions |
A list definition: a |
sp_list |
A |
... |
Additional parameters passed to |
views |
If |
folders |
If |
call |
The execution environment of a currently
running function, e.g. |
dry_run |
If |
delete |
If |
allow_data_loss |
If |
Comparing columns
Columns are matched by internal name (name). Only the properties included
in a definition are compared, so a definition with text: {} matches any
text column. A property missing from a definition isn't changed.
SharePoint internal columns and the Title column are excluded unless
Title is included in the definitions. The built-in columns of a document
library (e.g. FileLeafRef or _ExtendedDescription) are also excluded
unless they're included in the definitions. Columns in the list that aren't in
the definitions are returned with action = "delete".
Each change has one of these actions:
"add": the column or view isn't in the list.
"update": a property is different.
"delete": the column or view isn't in the definitions.
"blocked": the change can't be made. This includes changing the column
type (e.g. text to number), changing a lookup column's source list,
adding a column type the Graph API can't create, adding a list column
with a name longer than 32 characters (which SharePoint would cut),
changing the list template, and removing the default view without
setting another default view.
"unverified": the current value can't be read with the Graph API. This
includes validation (which sync_sp_list() applies every time) and
columns where the Graph API doesn't return the column type (hyperlink,
picture, thumbnail, and term columns).
A column's internal name can't be changed. A renamed column is returned as a column to add and a column to delete.
If sp_list is a ms_list object and definitions is a list definition,
the list displayName, description, and list settings (hidden and
contentTypesEnabled) are also compared. A different template is blocked
since the template can't be changed after a list is created.
Comparing views
Views are only compared if the definition has a views element and views = TRUE. A definition without views never adds, changes, or deletes views.
Views are matched by Id (if included in the definition) or Title, so a
view with an Id can be renamed. Only the properties included in a view
definition are compared. Hidden and personal views are excluded, and views
in the list that aren't in the definition are returned with action = "delete".
Setting DefaultView: true makes a view the default view (and the current
default view is no longer the default). The current default view can't be
removed from the default or deleted unless another view is set as the
default view. Changes are applied in this order: new views, updated views,
the default view, and then deleted views.
Views are read and changed with the SharePoint REST API. Use views = FALSE to skip views (e.g. if the SharePoint REST API isn't available).
Comparing folders
Folders are only compared if the definition has a folders element,
folders = TRUE, and the list is a document library. Each folder path that
doesn't exist is returned with action = "add". A path that exists as a
file is blocked. Folders that aren't in the definition are never deleted.
Each folder path is checked with one request.
Changes that use the SharePoint REST API
SharePoint stores single and multiple lines of text and single and multiple
choice columns as different field types, and the Graph API can't change
them. These changes use the SharePoint REST API (method = "rest"):
text.allowMultipleLines: switching to multiple lines keeps existing
values. Switching to a single line truncates values longer than 255
characters, so it is skipped unless allow_data_loss = TRUE.
choice.displayAs to or from "checkBoxes": switching to multiple
choice keeps existing values. Switching to a single choice may drop
values from items with more than one choice, so it is skipped unless
allow_data_loss = TRUE.
validation: the Graph API can't create or update column validation.
All view changes.
The SharePoint REST API requires a delegated (user) login with a refresh token, such as the default Microsoft365R login.
compare_sp_list() returns a data frame with one row per added or
deleted column or view and one row per changed property, with columns:
object: "list", "column", "view", or "folder".
name: list display name, internal column name, view title, or folder
path.
id: column or view ID for existing columns and views.
action: one of "add", "update", "delete", "blocked", or
"unverified".
property: changed property, e.g. "displayName",
"text.allowMultipleLines", "list.hidden", or "RowLimit".
current, proposed: list columns with the current and proposed
values.
method: "graph" or "rest" for changes that can be applied.
data_loss: TRUE if the change may cause data loss.
note: explanation for blocked, unverified, or data loss changes.
sync_sp_list() invisibly returns the same data frame with a status
column: "planned" (for a dry run), "applied", "skipped",
"blocked", or "failed".
## Not run: definition <- read_sp_list_yaml("list-fields/capital-project.yaml") compare_sp_list(definition, site_url = "<SharePoint site url>") # Print planned changes sync_sp_list(definition, site_url = "<SharePoint site url>") # Apply changes sync_sp_list( definition, site_url = "<SharePoint site url>", dry_run = FALSE ) ## End(Not run)## Not run: definition <- read_sp_list_yaml("list-fields/capital-project.yaml") compare_sp_list(definition, site_url = "<SharePoint site url>") # Print planned changes sync_sp_list(definition, site_url = "<SharePoint site url>") # Apply changes sync_sp_list( definition, site_url = "<SharePoint site url>", dry_run = FALSE ) ## End(Not run)
copy_column_definition_list(sp_list = NULL, ...)copy_column_definition_list(sp_list = NULL, ...)
sp_list |
A |
... |
Arguments passed on to
|
copy_column_definition_list() takes an existing SharePoint list and uses
the list metadata to create a column definition list that can be used to
create a new SharePoint list. Note: lookup columns retain the original lookup
list references so self-referencing lookup columns are copied as lookup
columns referencing the source list.
A list of named lists, each formatted as a columnDefinition (as
created by create_column_definition()) for use as the fields
argument to create_sp_list().
create_column_definition() builds a named list with the properties of the
columnDefinition resource type. The create_*_column() helpers create a
definition for a single column type.
Arguments that set a columnDefinition property note the matching Graph
property name. Graph property names can also be passed to ... (e.g.
create_text_column("Notes", allowMultipleLines = TRUE) or
create_column_definition("Notes", displayName = "Project Notes")).
Column-level properties are added to the definition and any other values
are added to the properties for the column type. Supplying the same
property with both an argument and a Graph name is an error. Definitions
are checked with the same rules as as_column_definition().
Properties left as NULL aren't included in the definition so SharePoint
uses the default value when a column is created.
More information: https://learn.microsoft.com/en-us/graph/api/resources/columndefinition?view=graph-rest-1.0
create_column_definition( name, ..., .col_type = "text", enforce_unique = NULL, hidden = NULL, deletable = NULL, indexed = NULL, sealed = NULL, propagate_changes = NULL, read_only = NULL, required = NULL, validation = NULL, default = get_column_default(), description = NULL, display_name = NULL, id = NULL, displayname = deprecated(), call = current_env() ) create_text_column( name, ..., multiple_lines = NULL, append_changes = NULL, lines = NULL, max_length = NULL, text_type = NULL ) create_choice_column( name, choices, ..., allow_text = NULL, display_as = NULL, allow_na = TRUE, na_replacement = "NA", split = NULL ) create_number_column( name, ..., decimal_places = NULL, display_as = NULL, max = NULL, min = NULL, decimals = deprecated() ) create_datetime_column(name, ..., display_as = NULL, format = NULL) create_boolean_column(name, ...) create_currency_column(name, ..., locale = NULL) create_calculated_column(name, ..., formula, format = NULL, output_type = NULL) create_lookup_column( name, lookup_list_column = NULL, ..., lookup_list_id = NULL, lookup_list = NULL, allow_multiple_values = NULL, allow_unlimited_length = NULL, primary_lookup_column_id = NULL, allow_multiple = deprecated() ) create_person_column( name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleOnly", allow_multiple = deprecated() ) create_group_column( name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleAndGroups", allow_multiple = deprecated() ) create_hyperlink_column(name, ..., is_picture = FALSE) create_picture_column(name, ..., is_picture = TRUE) create_thumbnail_column(name, ...) create_geolocation_column(name, ...) create_term_column( name, ..., allow_multiple_values = NULL, show_full_name = NULL, allow_multiple = deprecated() )create_column_definition( name, ..., .col_type = "text", enforce_unique = NULL, hidden = NULL, deletable = NULL, indexed = NULL, sealed = NULL, propagate_changes = NULL, read_only = NULL, required = NULL, validation = NULL, default = get_column_default(), description = NULL, display_name = NULL, id = NULL, displayname = deprecated(), call = current_env() ) create_text_column( name, ..., multiple_lines = NULL, append_changes = NULL, lines = NULL, max_length = NULL, text_type = NULL ) create_choice_column( name, choices, ..., allow_text = NULL, display_as = NULL, allow_na = TRUE, na_replacement = "NA", split = NULL ) create_number_column( name, ..., decimal_places = NULL, display_as = NULL, max = NULL, min = NULL, decimals = deprecated() ) create_datetime_column(name, ..., display_as = NULL, format = NULL) create_boolean_column(name, ...) create_currency_column(name, ..., locale = NULL) create_calculated_column(name, ..., formula, format = NULL, output_type = NULL) create_lookup_column( name, lookup_list_column = NULL, ..., lookup_list_id = NULL, lookup_list = NULL, allow_multiple_values = NULL, allow_unlimited_length = NULL, primary_lookup_column_id = NULL, allow_multiple = deprecated() ) create_person_column( name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleOnly", allow_multiple = deprecated() ) create_group_column( name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleAndGroups", allow_multiple = deprecated() ) create_hyperlink_column(name, ..., is_picture = FALSE) create_picture_column(name, ..., is_picture = TRUE) create_thumbnail_column(name, ...) create_geolocation_column(name, ...) create_term_column( name, ..., allow_multiple_values = NULL, show_full_name = NULL, allow_multiple = deprecated() )
name |
Column name. Graph property: |
... |
Additional arguments passed to |
.col_type |
Column type. Defaults to "text". Must be one of "boolean", "calculated", "choice", "currency", "dateTime", "lookup", "number", "personOrGroup", "text", "term", "hyperlinkOrPicture", "thumbnail", "contentApprovalStatus", or "geolocation". |
enforce_unique |
Enforce unique values in column. Graph property:
|
|
If |
|
deletable |
If |
indexed, sealed, propagate_changes, read_only, id
|
Additional arguments
used by |
required |
If |
validation |
Column validation created with |
default |
Default value set by helper |
description |
Column description. Graph property: |
display_name |
Column display name. Graph property: |
displayname |
|
call |
The execution environment used in error messages. The
|
multiple_lines |
Logical. If |
append_changes |
Logical. If |
lines |
Whole number. Size of the text box. Graph property:
|
max_length |
Whole number. Max length in number of characters. Graph
property: |
text_type |
One of |
choices |
A character vector of choice options. Graph property:
|
allow_text |
If |
display_as |
Value displayed as option. For |
allow_na |
If |
na_replacement |
Used as |
split |
character vector (or object which can be coerced to such)
containing regular expression(s) (unless |
decimal_places |
One of |
max, min
|
Minimum and maximum values allowed in number column. Graph
properties: |
decimals |
|
format |
For |
locale |
Locale used to set the currency symbol, e.g. |
formula |
Required string with formula for calculated column definition.
See examples of common formulas in lists.
Reference existing columns using the display name enclosed in square
brackets. The formula must start with an equals sign |
output_type |
Value type returned by calculated formula. One of
|
lookup_list_column |
Name of lookup column in the lookup list to use.
Graph property: |
lookup_list_id, lookup_list
|
Lookup list ID string or "ms_list" class
object with id value in list properties. Graph property: |
allow_multiple_values |
If |
allow_unlimited_length |
If |
primary_lookup_column_id |
If column definition is for a secondary
column, the primary lookup column ID must be supplied. Graph property:
|
allow_multiple |
|
allow_multiple_selection |
If |
from_type |
What type of resources to choose from. Defaults to
"peopleOnly" for |
is_picture |
Logical indicator for display of hyperlink value as link
( |
show_full_name |
If |
Display as options
Display as options vary by columnDefinition type. See documentation for more details:
personOrGroupColumn: https://learn.microsoft.com/en-us/graph/api/resources/personorgroupcolumn?view=graph-rest-1.0#displayas-options
choiceColumn: https://learn.microsoft.com/en-us/graph/api/resources/choicecolumn?view=graph-rest-1.0#properties
numberColumn: https://learn.microsoft.com/en-us/graph/api/resources/numbercolumn?view=graph-rest-1.0#properties
dateTimeColumn: https://learn.microsoft.com/en-us/graph/api/resources/datetimecolumn?view=graph-rest-1.0
Column types the Graph API can't create
As of October 2026, the Graph API returns an "Invalid request" error when
creating a list column with the hyperlinkOrPicture, thumbnail, geolocation,
or term column types. create_hyperlink_column(),
create_picture_column(), create_thumbnail_column(),
create_geolocation_column(), and create_term_column() still create
valid definitions, but create_sp_list_column() can't use them. The Graph
API also doesn't return the column type for hyperlinkOrPicture, thumbnail,
or term columns when reading list columns.
Term columns also need a term set, which isn't supported.
A named list of columnDefinition properties formatted for use as
the columns argument to create_sp_list() or as an element of the list
returned by create_column_definition_list().
create_text_column("TextColumn") create_text_column("NotesColumn", multiple_lines = TRUE) # Graph property names are also supported create_text_column("NotesColumn", allowMultipleLines = TRUE) fruit <- c("apple", "banana", "pear", "pineapple") create_choice_column("ChoiceColumn", fruit) create_number_column("NumberColumn") create_number_column("PercentColumn", display_as = "percentage", max = 1) create_datetime_column("DatetimeColumn") create_datetime_column("DateColumn", format = "dateOnly") create_calculated_column( name = "FormulaColumn", formula = "=[Text Column]" )create_text_column("TextColumn") create_text_column("NotesColumn", multiple_lines = TRUE) # Graph property names are also supported create_text_column("NotesColumn", allowMultipleLines = TRUE) fruit <- c("apple", "banana", "pear", "pineapple") create_choice_column("ChoiceColumn", fruit) create_number_column("NumberColumn") create_number_column("PercentColumn", display_as = "percentage", max = 1) create_datetime_column("DatetimeColumn") create_datetime_column("DateColumn", format = "dateOnly") create_calculated_column( name = "FormulaColumn", formula = "=[Text Column]" )
create_column_definition_list() is a vectorized version of
create_column_definition() that uses a list or data frame input to create
a list of column definitions. This list can be used as the columns argument
for create_sp_list().
create_column_definition_list(definitions, col_type = "text", ignore_na = TRUE)create_column_definition_list(definitions, col_type = "text", ignore_na = TRUE)
definitions |
A list or data frame with arguments to use in creation of column definitions. |
col_type |
Column type to use if not provided as a "type" column in the
input definitions data frame. Allowed values include the Graph column type
keys (e.g. "dateTime" or "personOrGroup") and the shorter names date,
datetime, person, group, hyperlink, and picture. Not case sensitive. A
"date" column uses |
ignore_na |
If |
Columns in definitions can use the argument names of the
create_*_column() helpers (e.g. multiple_lines) or Graph property names
(e.g. allowMultipleLines). See create_column_definition() for details.
A list of named lists, one per row of definitions, each
formatted as a columnDefinition (as created by
create_column_definition()) for use as the columns argument to
create_sp_list().
definition_df <- data.frame( name = c("FirstColumn", "SecondColumn"), type = c("text", "number"), decimal_places = c(NA, 0), multiple_lines = c(TRUE, NA) ) create_column_definition_list(definition_df)definition_df <- data.frame( name = c("FirstColumn", "SecondColumn"), type = c("text", "number"), decimal_places = c(NA, 0), multiple_lines = c(TRUE, NA) ) create_column_definition_list(definition_df)
create_sp_drive() creates a document library on a SharePoint site and
returns the library's drive as a ms_drive object. A document library is a
SharePoint list created with the "documentLibrary" template, so this
function wraps create_sp_list(). Columns, views, and folders can be
supplied with a list definition (see read_sp_list_yaml()).
The library's list can be used with the list functions (e.g.
compare_sp_list() or sync_sp_list()) and the drive can be used with the
file and folder functions (e.g. sp_dir_create() or upload_sp_item()).
create_sp_drive() doesn't create a SharePoint Embedded container (a Graph
fileStorageContainer). Containers aren't part of a SharePoint site and can
only be created by an app that owns a registered container type.
create_sp_drive( drive_name = NULL, description = NULL, ..., folders = NULL, definition = NULL, properties = FALSE, site_url = NULL, site = NULL, call = caller_env() )create_sp_drive( drive_name = NULL, description = NULL, ..., folders = NULL, definition = NULL, properties = FALSE, site_url = NULL, site = NULL, call = caller_env() )
drive_name |
Library name used as the |
description |
Optional description. |
... |
Additional parameters passed to |
folders |
Optional. A character vector of folder paths to create,
relative to the library root (e.g. |
definition |
Optional. A list definition from |
properties |
If |
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 |
call |
The execution environment of a currently
running function, e.g. |
A ms_drive object for the new library, or the drive properties
as a named list if properties = TRUE.
update_sp_drive(), delete_sp_drive(), create_sp_list(),
get_sp_drive()
## Not run: create_sp_drive( "Project Files", folders = c("Contracts", "Reports/2026"), site_url = "<SharePoint site url>" ) create_sp_drive( definition = "library-fields/project-files.yaml", site_url = "<SharePoint site url>" ) ## End(Not run)## Not run: create_sp_drive( "Project Files", folders = c("Contracts", "Reports/2026"), site_url = "<SharePoint site url>" ) create_sp_drive( definition = "library-fields/project-files.yaml", site_url = "<SharePoint site url>" ) ## End(Not run)
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 in columns or definition updates the default
"Title" column of a "genericList" list (combined with
title_definition) or a "documentLibrary" library instead of adding a
new column.
Views in definition are 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 definition are created after the views for a
"documentLibrary" library. Use create_sp_drive() to create a document
library and return the ms_drive object.
Notes on updating a SharePoint list:
The "Title" column type is always a "text" type column and can't be
changed.
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() )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() )
list_name |
List name used as |
... |
Additional parameters passed to |
description |
Optional description. |
columns |
Optional. Use |
template |
Optional list template (Graph listInfo property |
content_types |
Optional. Set |
|
Optional. Set |
|
title_definition |
Named list used to update the column definition of
the default |
definition |
Optional. A list definition from |
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 |
call |
The execution environment of a currently
running function, e.g. |
list_id |
List ID for list to update or delete. |
sp_list |
A |
display_name |
Display name to replace existing display name. Used by
|
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
confirm |
If |
For create_sp_list(), invisibly returns a ms_list object for
the newly created list. For update_sp_list(), the updated ms_list
object. For delete_sp_list(), invisibly returns NULL.
## Not run: create_sp_list( definition = "list-fields/capital-project.yaml", site_url = "<SharePoint site url>" ) ## End(Not run)## Not run: create_sp_list( definition = "list-fields/capital-project.yaml", site_url = "<SharePoint site url>" ) ## End(Not run)
create_sp_list_column() adds a column to a SharePoint list and
delete_sp_list_column() removes a column to a SharePoint list.
update_sp_list_column() updates a column definition for an existing column
in a SharePoint list. Only properties that differ from the existing column
are sent. Use sync_sp_list() for changes the Graph API can't make,
such as switching a text column to multiple lines.
create_sp_list_column( sp_list = NULL, ..., column_name = NULL, column_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) update_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, column_definition = NULL, column_name_type = "name", call = caller_env() ) delete_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, list_name = NULL, site_url = NULL, site = NULL, column_name_type = "name", call = caller_env() )create_sp_list_column( sp_list = NULL, ..., column_name = NULL, column_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) update_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, column_definition = NULL, column_name_type = "name", call = caller_env() ) delete_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, list_name = NULL, site_url = NULL, site = NULL, column_name_type = "name", call = caller_env() )
sp_list |
A |
... |
Arguments passed on to
|
column_name, column_id
|
Column ID for column to delete. |
column_definition |
List with column definition created with
|
list_name |
List name. Required if |
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 |
call |
The execution environment of a currently
running function, e.g. |
column_name_type |
"name" or "displayName". Used to match column ID so
column_name must be unique if |
See documentation: https://learn.microsoft.com/en-us/graph/api/list-post-columns?view=graph-rest-1.0&tabs=http
For create_sp_list_column(), a named list with the newly
created columnDefinition resource. For update_sp_list_column(),
invisibly returns the input sp_list. For delete_sp_list_column(), an
empty list with a "status" attribute giving the HTTP response status
code.
Create or update list items
create_sp_list_items( data, list_name = NULL, list_id = NULL, sp_list = NULL, ..., allow_display_nm = FALSE, .id = "id", site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, check_fields = TRUE, sync_fields = FALSE, create_list = FALSE, strict = FALSE, .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() ) update_sp_list_items( data, list_name = NULL, list_id = NULL, sp_list = NULL, ..., .id = "id", allow_display_nm = FALSE, check_fields = TRUE, strict = FALSE, na_fields = c("drop", "replace"), drop_fields = c("ContentType", "Attachments"), .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() ) update_sp_list_item( ..., .data = NULL, item_id = NULL, sp_list_item = NULL, .id = "id", check_fields = TRUE, na_fields = c("drop", "replace"), drop_fields = c("ContentType", "Attachments"), list_name = NULL, list_id = NULL, sp_list = NULL, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, .multi_fields = NULL, call = caller_env() )create_sp_list_items( data, list_name = NULL, list_id = NULL, sp_list = NULL, ..., allow_display_nm = FALSE, .id = "id", site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, check_fields = TRUE, sync_fields = FALSE, create_list = FALSE, strict = FALSE, .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() ) update_sp_list_items( data, list_name = NULL, list_id = NULL, sp_list = NULL, ..., .id = "id", allow_display_nm = FALSE, check_fields = TRUE, strict = FALSE, na_fields = c("drop", "replace"), drop_fields = c("ContentType", "Attachments"), .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() ) update_sp_list_item( ..., .data = NULL, item_id = NULL, sp_list_item = NULL, .id = "id", check_fields = TRUE, na_fields = c("drop", "replace"), drop_fields = c("ContentType", "Attachments"), list_name = NULL, list_id = NULL, sp_list = NULL, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, .multi_fields = NULL, call = caller_env() )
data |
Required. A data frame or a list of named lists (one record per
item) to import as items to the supplied or identified SharePoint list. If
data is an sf object, the geometry column is coerced to text using
|
list_name, list_id
|
SharePoint List name or ID string. |
sp_list |
A |
... |
Additional parameters passed to |
allow_display_nm |
If |
.id |
Name of the column in |
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 |
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
check_fields |
If |
sync_fields |
If |
create_list |
If |
strict |
If |
.batch |
If |
.progress |
Whether to show a progress bar. Use |
call |
The execution environment of a currently
running function, e.g. |
na_fields |
How to handle |
drop_fields |
Column names to drop from |
.data |
A list or data frame with fields to update. |
item_id |
A SharePoint list item id. Either |
sp_list_item |
Optional. A SharePoint list item object to update. |
.multi_fields |
Optional. Names of multi-value (Collection) fields, such
as multi-select choice columns, that should always be sent as an array with
an |
Validation of data with with create_sp_list_items()
The handling of item creation when column names in data do not match the
fields names in the supplied list includes a few options:
If no names in data match fields in the list, the function errors and lists the field names.
If all names in data match fields in the list the records are created. Any fields that do not have corresponding names in data remain blank.
If any names in data do not match fields in the list, by default, those columns are dropped before adding items to the list.
If strict = TRUE and any names in data to not match fields, the function
errors.
create_sp_list_items() and update_sp_list_items() invisibly
return the input data, unmodified (even if data is empty).
sp_list_url <- "<SharePoint List URL with a Name field>" if (is_sp_url(sp_list_url)) { create_sp_list_items( data = data.frame( Name = c("Jim", "Jane", "Jayden") ), list_name = sp_list_url ) }sp_list_url <- "<SharePoint List URL with a Name field>" if (is_sp_url(sp_list_url)) { create_sp_list_items( data = data.frame( Name = c("Jim", "Jane", "Jayden") ), list_name = sp_list_url ) }
update_sp_list_person_items() is a variant of
update_sp_list_lookup_items() for person or group columns. Person or group
columns are a type of lookup column where the lookup list is the hidden
"User Information List" for the site. By default, users are matched by email
address (ignoring case). Users that have never accessed the site are not
included in the "User Information List" and can't be matched.
create_sp_list_lookup_column( sp_list = NULL, column_name, lookup_list, lookup_list_column = column_name, ..., list_name = NULL, site = NULL, site_url = NULL, call = caller_env() ) create_sp_list_person_column( sp_list = NULL, column_name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleOnly", list_name = NULL, site = NULL, site_url = NULL, allow_multiple = deprecated(), call = caller_env() ) update_sp_list_lookup_items( data = NULL, sp_list = NULL, column_name, lookup_list_data = NULL, lookup_list = NULL, join_column = column_name, lookup_join_column = join_column, ..., .id = "id", ignore_case = FALSE, na_fields = c("drop", "replace"), .progress = TRUE, call = caller_env() ) fmt_sp_list_lookup_items( data, column_name, lookup_list_data = NULL, lookup_list = NULL, lookup_join_column = column_name, ..., .id = "id", ignore_case = FALSE, call = caller_env() ) update_sp_list_person_items( data = NULL, sp_list = NULL, column_name, join_column = column_name, user_column = "EMail", user_info_data = NULL, allow_hidden = FALSE, ..., .id = "id", na_fields = c("drop", "replace"), .progress = TRUE, call = caller_env() )create_sp_list_lookup_column( sp_list = NULL, column_name, lookup_list, lookup_list_column = column_name, ..., list_name = NULL, site = NULL, site_url = NULL, call = caller_env() ) create_sp_list_person_column( sp_list = NULL, column_name, ..., allow_multiple_selection = NULL, display_as = NULL, from_type = "peopleOnly", list_name = NULL, site = NULL, site_url = NULL, allow_multiple = deprecated(), call = caller_env() ) update_sp_list_lookup_items( data = NULL, sp_list = NULL, column_name, lookup_list_data = NULL, lookup_list = NULL, join_column = column_name, lookup_join_column = join_column, ..., .id = "id", ignore_case = FALSE, na_fields = c("drop", "replace"), .progress = TRUE, call = caller_env() ) fmt_sp_list_lookup_items( data, column_name, lookup_list_data = NULL, lookup_list = NULL, lookup_join_column = column_name, ..., .id = "id", ignore_case = FALSE, call = caller_env() ) update_sp_list_person_items( data = NULL, sp_list = NULL, column_name, join_column = column_name, user_column = "EMail", user_info_data = NULL, allow_hidden = FALSE, ..., .id = "id", na_fields = c("drop", "replace"), .progress = TRUE, call = caller_env() )
sp_list |
A |
column_name |
Name of the lookup (or person or group) column. For
|
lookup_list |
The lookup list as a |
lookup_list_column |
Name of lookup column in the lookup list to use.
Graph property: |
... |
Arguments passed on to
|
list_name |
List name. Required if |
site |
A |
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. |
call |
The execution environment of a currently
running function, e.g. |
allow_multiple_selection |
If |
display_as |
Value displayed as option. For |
from_type |
What type of resources to choose from. Defaults to
"peopleOnly" for |
allow_multiple |
|
data |
Optional. A data frame, a list of named lists (one record per
item), or a single named list record with item ID values ( |
lookup_list_data |
Optional. A data frame or a list of named lists
with item ID values ( |
join_column |
Name of column (or record element) in |
lookup_join_column |
Name of column (or record element) in
|
.id |
Name of column (or record element) with item ID values in |
ignore_case |
If |
na_fields |
How to handle |
.progress |
Whether to show a progress bar. Use |
user_column |
Name of column (or record element) in |
user_info_data |
Optional. A data frame or an unnamed list of named
lists from the "User Information List" for the site. If |
|
If |
create_sp_list_lookup_column() is a wrapper for create_lookup_column()
and create_sp_list_column() that creates a lookup column in a list
(sp_list) using a column from a second list in the same site (the "lookup"
list). create_sp_list_person_column() is a wrapper for
create_person_column() and create_sp_list_column() that creates a person
or group column.
fmt_sp_list_lookup_items() formats one or more lookup (or person or group)
columns in data by replacing the values with matching lookup list item ID
values and renaming the columns to "{column_name}LookupId". Use the output
with create_sp_list_items() or update_sp_list_items().
Values in data that can't be matched to a lookup list item are listed in a
message and replaced with NA values. Missing values are never matched.
data_as_column_definition_list() is used to create a column definition list
based on an existing data frame. This function is used internally by
create_sp_list_items() when create_list = TRUE.
data_as_column_definition_list( data, ..., split = "|", ignore_na = TRUE, definitions_as = c("definition_list", "table") )data_as_column_definition_list( data, ..., split = "|", ignore_na = TRUE, definitions_as = c("definition_list", "table") )
data |
A data frame input. Column types are used to infer the appropriate Microsoft Lists column definition. |
... |
Ignored. |
split |
character vector (or object which can be coerced to such)
containing regular expression(s) (unless |
ignore_na |
If |
definitions_as |
If |
Converting R data types to SharePoint column definitions
The type for each vector in the input data frame is checked with
vctrs::vec_ptype_abbr and mapped to corresponding SharePoint list column
definitions:
factors are specified as choice columns
integers are specified as number columns with decimal_places set to "none"
characters with any value exceeding 255 characters have multiple_lines set to TRUE
characters composed entirely of URL values are specified as hyperlink columns
dates are specified as date columns
dttm values are specified as datetime columns
logical values are specified as boolean columns if they include no NA values or text columns if they do
All other vectors are specified as text columns.
If the levels of any input factor column contain the character specified with split, this function errors.
If definitions_as = "definition_list" (default), a list of
named lists formatted as columnDefinitions for use as the fields
argument to create_sp_list(). If definitions_as = "table", a data
frame with one row per column of data describing the inferred name,
type, and other definition properties.
data_as_column_definition_list(mtcars)data_as_column_definition_list(mtcars)
delete_sp_item() deletes items including files and directories using the
delete method for . By default confirm = TRUE, which requires the user to
respond to a prompt: "Do you really want to delete the drive item ...?
(yes/No/cancel)" to continue.
delete_sp_item( path = NULL, confirm = TRUE, by_item = FALSE, ..., item_id = NULL, item_url = NULL, item = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() )delete_sp_item( path = NULL, confirm = TRUE, by_item = FALSE, ..., item_id = NULL, item_url = NULL, item = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() )
path |
A SharePoint file URL or the relative path to a file located in a
SharePoint drive. If input is a relative path, the string should not
include the drive name. If input is a shared file URL, the text "Shared "
is removed from the start of the SharePoint drive name by default. If file
is a document URL, the |
confirm |
If |
by_item |
For business OneDrive or SharePoint document libraries, you
may need to set |
... |
Arguments passed on to
|
item_id |
A SharePoint item ID passed to the |
item_url |
A SharePoint item URL used to parse the item ID, drive name, and site URL. |
item |
A |
drive_name, drive_id
|
SharePoint drive name or ID. |
drive |
A |
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. |
call |
The execution environment of a currently
running function, e.g. |
Trouble-shooting errors
If you get the error: "The resource you are attempting to access is locked", you or another user may have the file or a file within the directory open for editing. Close the file and try deleting the item again.
If you get the error: "Request was cancelled by event received. If attempting
to delete a non-empty folder, it's possible that it's on hold." set by_item = TRUE and try again.
Invisibly returns NULL.
delete_sp_list_item() deletes a single SharePoint list item and
delete_sp_list_items() deletes multiple SharePoint list items. Set
confirm = FALSE to use without interactive confirmation.
delete_sp_list_item( item_id = NULL, sp_list_item = NULL, ..., .id = "id", list_name = NULL, list_id = NULL, sp_list = NULL, site_url = NULL, site = NULL, confirm = TRUE, call = caller_env() ) delete_sp_list_items( item_id = NULL, ..., .id = "id", sp_list = NULL, filter = NULL, confirm = TRUE, .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() )delete_sp_list_item( item_id = NULL, sp_list_item = NULL, ..., .id = "id", list_name = NULL, list_id = NULL, sp_list = NULL, site_url = NULL, site = NULL, confirm = TRUE, call = caller_env() ) delete_sp_list_items( item_id = NULL, ..., .id = "id", sp_list = NULL, filter = NULL, confirm = TRUE, .batch = getOption("sharepointr.batch", TRUE), .progress = TRUE, call = caller_env() )
item_id |
ID value for list item or items to delete. |
sp_list_item |
Optional. A SharePoint list item object to delete. |
... |
For |
.id |
Name of column (if |
list_name, list_id
|
SharePoint List name or ID string. |
sp_list |
A |
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 |
confirm |
If |
call |
The execution environment of a currently
running function, e.g. |
filter |
Optional. A string with an OData filter expression used to
find the items to delete if |
.batch |
If |
.progress |
Whether to show a progress bar. Use |
For delete_sp_list_item(), invisibly returns an empty list with
a "status" attribute giving the HTTP response status code. For
delete_sp_list_items(), invisibly returns a list of these responses,
one per deleted item.
download_sp_item() wraps the download method for SharePoint items making
it easier to download items based on a shared file URL or document URL.
download_sp_item( path = NULL, new_path = "", ..., item_id = NULL, item_url = NULL, item = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, dest = NULL, overwrite = FALSE, recursive = FALSE, parallel = FALSE, call = caller_env() ) download_sp_file(file, new_path = "", ..., call = caller_env())download_sp_item( path = NULL, new_path = "", ..., item_id = NULL, item_url = NULL, item = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, dest = NULL, overwrite = FALSE, recursive = FALSE, parallel = FALSE, call = caller_env() ) download_sp_file(file, new_path = "", ..., call = caller_env())
path, file
|
Required. A SharePoint shared file URL, document URL, or, if
|
new_path |
Path to directory for downloaded item. Optional if |
... |
Arguments passed on to
|
item_id |
A SharePoint item ID passed to the |
item_url |
A SharePoint item URL used to parse the item ID, drive name, and site URL. |
item |
A |
drive_name, drive_id
|
SharePoint drive name or ID. |
drive |
A |
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. |
dest, overwrite, recursive, parallel
|
Parameters passed to |
call |
The execution environment of a currently
running function, e.g. |
The default value for path is "" so, by default, SharePoint items are
downloaded to the current working directory. Set overwrite = TRUE to allow
this function to overwrite an existing file. download_sp_file() is
identical except for the name of the path parameter (which is file instead of
path).
Note, if the selected item is a folder and recurse = TRUE, it may
take some time to download the enclosed items and {Microsoft365R} does not
provide a progress bar for that operation.
Invisibly returns the input dest or the dest parsed from the
input path or item properties.
If provided with a vector of paths or a vector of item ID values,
download_sp_item() can execute a batch download on a set of files or
folders. Make sure to supply a vector to new_path or dest vector with the
directory names or file names to use as a destination for the downloads. With
either option, you must supply a drive, a drive_name and site, or a
drive_url. You can also pass a bare list of items and the value for the
dest can be inferred from the item properties. If {carrier} and
{mirai} are installed and mirai::daemons() are set, items are downloaded
in parallel. The parallel argument is separate: it is passed to the
download method to download the contents of a folder in parallel.
# Download a single directory sp_dir_url <- "<SharePoint directory url>" new_path <- "local file path" if (is_sp_url(sp_dir_url)) { download_sp_item( sp_dir_url, new_path = new_path, recursive = TRUE ) } # Batch download multiple directories from a SharePoint Drive sp_drive_url <- "<SharePoint Drive url>" if (is_sp_url(sp_drive_url)) { drive <- get_sp_drive(drive_name = sp_drive_url) drive_dir_list <- sp_dir_info( drive = drive, recurse = TRUE, type = "dir" ) download_sp_item( item_id = drive_dir_list$id, dest = drive_dir_list$name, recursive = TRUE, drive = drive ) }# Download a single directory sp_dir_url <- "<SharePoint directory url>" new_path <- "local file path" if (is_sp_url(sp_dir_url)) { download_sp_item( sp_dir_url, new_path = new_path, recursive = TRUE ) } # Batch download multiple directories from a SharePoint Drive sp_drive_url <- "<SharePoint Drive url>" if (is_sp_url(sp_drive_url)) { drive <- get_sp_drive(drive_name = sp_drive_url) drive_dir_list <- sp_dir_info( drive = drive, recurse = TRUE, type = "dir" ) download_sp_item( item_id = drive_dir_list$id, dest = drive_dir_list$name, recursive = TRUE, drive = drive ) }
download_sp_list() downloads a SharePoint list to a CSV or XLSX file.
keep_list_cols is intended to allow the preservation of list columns but it
is not yet supported.
download_sp_list( ..., new_path = "", sp_list = NULL, fileext = "csv", keep_list_cols = c("createdBy", "lastModifiedBy"), call = caller_env() )download_sp_list( ..., new_path = "", sp_list = NULL, fileext = "csv", keep_list_cols = c("createdBy", "lastModifiedBy"), call = caller_env() )
... |
Arguments passed on to
|
new_path |
Optional path to new file. If not |
sp_list |
SharePoint list object. If supplied, all parameters supplied
to |
fileext |
File extension to use for output file. Must be |
keep_list_cols |
Column names for those columns to maintain in a list format instead of attempting to convert to a character vector. |
call |
The execution environment of a currently
running function, e.g. |
Invisibly returns the path to the downloaded file.
get_sp_group() gets the group associated with an individual site using the
get_group method. list_sp_group_members() lists members in the group.
Note that, as of February 1, 2024, the returned member data frame when
as_data_frame = TRUE contains a large number of list columns that could be
coerced into character columns. This should be addressed in a later update.
get_sp_group( site_url = NULL, site_name = NULL, site_id = NULL, ..., site = NULL, call = caller_env() ) list_sp_group_members( site_url = NULL, site_name = NULL, site_id = NULL, ..., sp_group = NULL, as_data_frame = TRUE, call = caller_env() )get_sp_group( site_url = NULL, site_name = NULL, site_id = NULL, ..., site = NULL, call = caller_env() ) list_sp_group_members( site_url = NULL, site_name = NULL, site_id = NULL, ..., sp_group = NULL, as_data_frame = TRUE, call = caller_env() )
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_name, site_id
|
Site name or ID of the SharePoint site as an
alternative to the SharePoint site URL. Exactly one of |
... |
Additional parameters passed to |
site |
A |
call |
The execution environment of a currently
running function, e.g. |
sp_group |
A "az_group" object returned by |
as_data_frame |
If |
For get_sp_group(), an az_group object for the site. For
list_sp_group_members(), a data frame of group members if
as_data_frame = TRUE (default), or a list of az_user objects if
FALSE.
get_sp_item() wraps the get_item method for ms_drive objects and
returns a ms_drive_item object by default. Additional parameters in ...
are passed to get_sp_drive().
Use get_sp_item_properties() to get the item properties instead. Setting
properties = TRUE returns the same properties, but only
get_sp_item_properties() can include the document library column values
(fields) for the item.
If path or item_url is a SharePoint URL for a file or folder (e.g. a
link from "Copy link" in SharePoint, a document URL, or a document library
URL) and item_id, drive_name, drive_id, and drive aren't supplied,
get_sp_item() gets the item with the Microsoft Graph shares API. This works for
items in any document library and for links to items that have been moved.
The Microsoft Graph login uses site, site_url, or the site in the URL.
If the shares API request fails, the site, drive, and path or item ID are
parsed from the URL instead.
get_sp_item( path = NULL, item_id = NULL, item_url = NULL, ..., drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, properties = FALSE, as_data_frame = FALSE, call = caller_env() )get_sp_item( path = NULL, item_id = NULL, item_url = NULL, ..., drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, properties = FALSE, as_data_frame = FALSE, call = caller_env() )
path |
A SharePoint file URL or the relative path to a file located in a
SharePoint drive. If input is a relative path, the string should not
include the drive name. If input is a shared file URL, the text "Shared "
is removed from the start of the SharePoint drive name by default. If file
is a document URL, the |
item_id |
A SharePoint item ID passed to the |
item_url |
A SharePoint item URL used to parse the item ID, drive name, and site URL. |
... |
Arguments passed on to
|
drive_name, drive_id
|
SharePoint drive name or ID. |
drive |
A |
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. |
properties |
If |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
A ms_drive_item object (or a list of item properties if
properties = TRUE), or a 1 row data frame if as_data_frame = TRUE.
get_sp_item_properties(), Microsoft365R::ms_drive_item
sp_item_url <- "<SharePoint item url>" if (is_sp_url(sp_item_url)) { get_sp_item( item_url = sp_item_url ) }sp_item_url <- "<SharePoint item url>" if (is_sp_url(sp_item_url)) { get_sp_item( item_url = sp_item_url ) }
get_sp_list_column() gets a list column definition for a single column
specified by column name or ID.
get_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, column_name_type = "name", call = caller_env() )get_sp_list_column( sp_list = NULL, column_name = NULL, column_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, column_name_type = "name", call = caller_env() )
sp_list |
A |
column_name, column_id
|
Column name or ID to get a definition for. |
... |
Arguments passed on to
|
list_name |
SharePoint List name. Optional if |
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 |
column_name_type |
"name" or "displayName". Used to match column ID so
column_name must be unique if |
call |
The execution environment of a currently
running function, e.g. |
See the Get columnDefinition Graph API documentation for more information.
A named list with the columnDefinition resource for the matched column.
list_sp_drives() loads a SharePoint site uses the list_drives method to
returns a data frame with a list column or ms_drive objects or, if
as_data_frame = FALSE. This is helpful if a drive has been renamed and
can't easily be identified using a Drive URL alone.
list_sp_drives( ..., site = NULL, filter = NULL, n = NULL, as_data_frame = TRUE, call = caller_env() )list_sp_drives( ..., site = NULL, filter = NULL, n = NULL, as_data_frame = TRUE, call = caller_env() )
... |
Arguments passed on to
|
site |
A |
filter |
Filter to apply to query |
n |
Max number of drives to return |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
A data frame with a list column of ms_drive objects if
as_data_frame = TRUE (default), or a list of ms_drive objects if
FALSE.
This is an implementation of a new method for a ms_item object using the
do_operation method directly. The intent is to add a list_versions method
back to the Microsoft365R package which may include changes to the
functionality and output of this function.
list_sp_item_versions(..., sp_item = NULL, as_data_frame = TRUE)list_sp_item_versions(..., sp_item = NULL, as_data_frame = TRUE)
... |
Arguments passed on to
|
sp_item |
SharePoint item to get versions for. Additional parameters
passed to |
as_data_frame |
If |
A data frame if as_data_frame = TRUE or a list if FALSE.
list_sp_list_views() lists the views for a SharePoint list.
get_sp_list_view() gets a single view by title or ID (or the default
view).
create_sp_list_view() creates a view.
update_sp_list_view() updates a view. Only properties that differ from
the existing view are changed.
delete_sp_list_view() deletes a view. The default view can't be deleted.
The Graph API doesn't support list views, so these functions use the
SharePoint REST API and require a delegated (user) login with a refresh
token, such as the default Microsoft365R login. View properties use the
SharePoint REST API
SP.View
property names (e.g. ViewFields or RowLimit) and the arguments use the
same names in snake case (e.g. view_fields or row_limit).
list_sp_list_views( sp_list = NULL, ..., hidden = FALSE, as_data_frame = TRUE, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) get_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) create_sp_list_view( sp_list = NULL, title = NULL, ..., view_fields = NULL, view_query = NULL, row_limit = NULL, paged = NULL, default_view = NULL, hidden = NULL, scope = NULL, custom_formatter = NULL, view_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) update_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., title = NULL, view_fields = NULL, view_query = NULL, row_limit = NULL, paged = NULL, default_view = NULL, hidden = NULL, scope = NULL, custom_formatter = NULL, view_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) delete_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., confirm = TRUE, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() )list_sp_list_views( sp_list = NULL, ..., hidden = FALSE, as_data_frame = TRUE, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) get_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) create_sp_list_view( sp_list = NULL, title = NULL, ..., view_fields = NULL, view_query = NULL, row_limit = NULL, paged = NULL, default_view = NULL, hidden = NULL, scope = NULL, custom_formatter = NULL, view_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) update_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., title = NULL, view_fields = NULL, view_query = NULL, row_limit = NULL, paged = NULL, default_view = NULL, hidden = NULL, scope = NULL, custom_formatter = NULL, view_definition = NULL, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() ) delete_sp_list_view( sp_list = NULL, view_title = NULL, view_id = NULL, ..., confirm = TRUE, list_name = NULL, site_url = NULL, site = NULL, call = caller_env() )
sp_list |
A |
... |
Additional arguments passed to |
|
For |
|
as_data_frame |
If |
list_name |
List name or URL. Used to get the list if |
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 |
call |
The execution environment of a currently
running function, e.g. |
view_title, view_id
|
Title or ID of an existing view. If both are
|
title |
View title. Required for |
view_fields |
Character vector of internal column names to show in
the view, in order. Use |
view_query |
A CAML query used to filter, sort, or group items (see
details). SP.View property: |
row_limit |
Number of items to show per page. SP.View property:
|
paged |
If |
default_view |
If |
scope |
For lists with folders, whether to show items in folders.
One of |
custom_formatter |
JSON view formatting as a JSON string or a list.
See Use view formatting to customize SharePoint.
SP.View property: |
view_definition |
Optional. A named list of SP.View properties (e.g.
|
confirm |
If |
View queries
view_query is a CAML
query with optional <Where>, <OrderBy>, and <GroupBy> elements (but
without an enclosing <Query> element). Reference columns by internal name.
For example, to show active items sorted by amount:
<Where><Eq><FieldRef Name="Status"/><Value Type="Choice">Active</Value></Eq></Where> <OrderBy><FieldRef Name="Amount" Ascending="FALSE"/></OrderBy>
Limitations
Board, gallery, and calendar views can be listed but their layout settings can't be changed.
Personal views can be listed but not created.
Hidden views include list form settings (e.g. a hidden "Untitled Form" view holds custom form formatting) and are excluded by default.
Changing view fields removes and re-adds every field. If a request fails
partway through, call update_sp_list_view() again.
Renaming a view doesn't change the view URL.
list_sp_list_views() returns a data frame or a list of views.
The data frame always has the same columns (Id, Title,
DefaultView, Hidden, ViewFields, ViewQuery, RowLimit, Paged,
Scope, CustomFormatter, MobileView, MobileDefaultView,
ServerRelativeUrl, ViewType, and PersonalView), even if the list
has no views. ViewFields is a list column and missing values are NA.
get_sp_list_view() returns a named list of SP.View properties (Id,
Title, ViewFields, ViewQuery, RowLimit, DefaultView, and other
properties). create_sp_list_view() and update_sp_list_view()
invisibly return the created or updated view in the same format.
delete_sp_list_view() invisibly returns NULL.
## Not run: list_sp_list_views(list_name = "Projects", site_url = "<SharePoint site url>") create_sp_list_view( sp_list, title = "Active Projects", view_fields = c("LinkTitle", "Status", "Amount"), view_query = '<Where><Eq><FieldRef Name="Status"/> <Value Type="Choice">Active</Value></Eq></Where>', row_limit = 50 ) update_sp_list_view( sp_list, view_title = "Active Projects", default_view = TRUE ) ## End(Not run)## Not run: list_sp_list_views(list_name = "Projects", site_url = "<SharePoint site url>") create_sp_list_view( sp_list, title = "Active Projects", view_fields = c("LinkTitle", "Status", "Amount"), view_query = '<Where><Eq><FieldRef Name="Status"/> <Value Type="Choice">Active</Value></Eq></Where>', row_limit = 50 ) update_sp_list_view( sp_list, view_title = "Active Projects", default_view = TRUE ) ## End(Not run)
list_sp_pages() returns a list of SharePoint pages associated with a
specified SharePoint site. get_sp_page() returns a single SharePoint page.
list_sp_pages( ..., site = NULL, page_type = c("sitePage", "page"), as_data_frame = TRUE, call = caller_env() ) get_sp_page(page_url = NULL, page_id = NULL, ..., site = NULL)list_sp_pages( ..., site = NULL, page_type = c("sitePage", "page"), as_data_frame = TRUE, call = caller_env() ) get_sp_page(page_url = NULL, page_id = NULL, ..., site = NULL)
... |
Arguments passed on to
|
site |
Optional |
page_type |
Page type to request. One of "sitePage" or "page". |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
page_url, page_id
|
SharePoint page URL or ID. |
For list_sp_pages(), a data frame with a list column of
ms_page objects if as_data_frame = TRUE (default), or a list of page
properties if FALSE. For get_sp_page(), a named list with the
properties of the matched sitePage.
list_sp_site_user_info( ..., sp_site = NULL, user_type = c("all", "visible"), filter = NULL, as_data_frame = TRUE, call = caller_env() )list_sp_site_user_info( ..., sp_site = NULL, user_type = c("all", "visible"), filter = NULL, as_data_frame = TRUE, call = caller_env() )
... |
Additional parameters passed to |
sp_site |
A |
user_type |
Type of users to return. "all" (default) returns all users
and "visible" excludes users where |
filter |
Optional. A filter query string passed to
|
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
list_sp_site_user_info() lists users from the hidden "User Information
List" for a site. Use the results to match users to lookup ID values for
person or group columns with fmt_sp_list_lookup_items() or
update_sp_list_person_items().
sp_dir_create() is a wrapper for the create_folder method that handles
character vectors. If drive_name is a folder URL and relative is TRUE,
the values for path are appended to the file path parsed from the url.
sp_dir_create( path, ..., drive_name = NULL, drive_id = NULL, drive = NULL, relative = FALSE, call = caller_env() )sp_dir_create( path, ..., drive_name = NULL, drive_id = NULL, drive = NULL, relative = FALSE, call = caller_env() )
path |
A character vector of one or more paths. |
... |
Arguments passed on to
|
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
relative |
If |
call |
The execution environment of a currently
running function, e.g. |
Invisibly returns the input path (or path combined with
relative if supplied).
drive_url <- "<link to SharePoint drive>" if (is_sp_url(drive_url)) { sp_dir_create( path = "parent_folder/subfolder", drive_name = drive_url ) sp_dir_create( path = c("subfolder1", "subfolder2", "subfolder3"), relative = "parent_folder", drive_name = drive_url ) } dir_url <- "<link to SharePoint directory>" if (is_sp_url(dir_url)) { sp_dir_create( path = c("subfolder1", "subfolder2", "subfolder3"), drive_name = dir_url, relative = TRUE ) }drive_url <- "<link to SharePoint drive>" if (is_sp_url(drive_url)) { sp_dir_create( path = "parent_folder/subfolder", drive_name = drive_url ) sp_dir_create( path = c("subfolder1", "subfolder2", "subfolder3"), relative = "parent_folder", drive_name = drive_url ) } dir_url <- "<link to SharePoint directory>" if (is_sp_url(dir_url)) { sp_dir_create( path = c("subfolder1", "subfolder2", "subfolder3"), drive_name = dir_url, relative = TRUE ) }
sp_dir_info() is a wrapper for the list_files method with some additional
features based on fs::dir_info(). sp_dir_ls() returns a character vector
and does not yet include support for the recurse argument. If
{fs} is installed, the size column is formatted using fs::as_fs_bytes()
and an additional "type" factor column is added with values for directory and
file.
sp_dir_info( path = NULL, ..., info = "partial", full_names = TRUE, pagesize = 1000, drive_name = NULL, drive_id = NULL, drive = NULL, recurse = FALSE, type = "any", regexp = NULL, invert = FALSE, perl = FALSE, call = caller_env() ) sp_dir_ls( path = NULL, ..., full_names = FALSE, pagesize = 1000, drive_name = NULL, drive_id = NULL, drive = NULL, type = "any", regexp = NULL, invert = FALSE, perl = FALSE, call = caller_env() )sp_dir_info( path = NULL, ..., info = "partial", full_names = TRUE, pagesize = 1000, drive_name = NULL, drive_id = NULL, drive = NULL, recurse = FALSE, type = "any", regexp = NULL, invert = FALSE, perl = FALSE, call = caller_env() ) sp_dir_ls( path = NULL, ..., full_names = FALSE, pagesize = 1000, drive_name = NULL, drive_id = NULL, drive = NULL, type = "any", regexp = NULL, invert = FALSE, perl = FALSE, call = caller_env() )
path |
Path to directory or folder. SharePoint folder URLs are allowed.
If |
... |
Arguments passed on to
|
info |
The information to return: "partial", "name" or "all". If "partial", a data frame is returned containing the name, size, ID and whether the item is a file or folder. If "all", a data frame is returned containing all the properties for each item (this can be large). |
full_names |
If |
pagesize |
Maximum number of items to return. Defaults to 1000. Decrease if you are experiencing timeouts. |
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
recurse |
If |
type |
Type of item to return. Can be "any", "file", or "directory".
"directory" is not a supported option for |
regexp |
Regular expression passed to |
invert |
logical. If |
perl |
logical. Should Perl-compatible regexps be used? |
call |
The execution environment of a currently
running function, e.g. |
For sp_dir_info(), a data frame with one row per file or folder
at path, with columns determined by info ("partial", "name", or
"all"). For sp_dir_ls(), a character vector of file and folder
names or paths.
dir_url <- "<link to SharePoint directory or drive>" if (is_sp_url(dir_url)) { sp_dir_info( path = dir_url ) sp_dir_ls( path = dir_url ) }dir_url <- "<link to SharePoint directory or drive>" if (is_sp_url(dir_url)) { sp_dir_info( path = dir_url ) sp_dir_ls( path = dir_url ) }
get_sp_drive() wraps the get_drive method returns a ms_drive object.
cache_sp_drive() allows you to cache a default SharePoint drive for use by
other functions. Additional parameters in ... are passed to
get_sp_drive().
get_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, properties = FALSE, ..., site_url = NULL, site = NULL, default_drive_name = getOption("sharepointr.default_drive_name", "Documents"), cache = getOption("sharepointr.cache", FALSE), refresh = getOption("sharepointr.refresh", TRUE), overwrite = FALSE, cache_file = NULL, call = caller_env() ) cache_sp_drive( ..., drive = NULL, cache_file = getOption("sharepointr.cache_file_drive", "sp_drive.rds"), overwrite = FALSE, call = caller_env() )get_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, properties = FALSE, ..., site_url = NULL, site = NULL, default_drive_name = getOption("sharepointr.default_drive_name", "Documents"), cache = getOption("sharepointr.cache", FALSE), refresh = getOption("sharepointr.refresh", TRUE), overwrite = FALSE, cache_file = NULL, call = caller_env() ) cache_sp_drive( ..., drive = NULL, cache_file = getOption("sharepointr.cache_file_drive", "sp_drive.rds"), overwrite = FALSE, call = caller_env() )
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive_url |
A SharePoint Drive URL to parse for a Drive name and other
information. If |
properties |
If |
... |
Arguments passed on to
|
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 |
default_drive_name |
Drive name string used only if input is a document
URL and drive name is not part of the URL. Defaults to
|
cache |
If |
refresh |
If |
overwrite |
If |
cache_file |
File name for cached drive or site. Default |
call |
The execution environment of a currently
running function, e.g. |
drive |
A |
For get_sp_drive(), a ms_drive object, or the drive
properties as a named list if properties = TRUE. For
cache_sp_drive(), invisibly returns NULL.
These functions copy or move items in a SharePoint document library. Their
interface is based on fs::file_copy(), fs::file_move(), and
fs::dir_copy():
sp_item_copy() copies files. Use sp_dir_copy() to copy folders.
sp_item_move() moves (or renames) files or folders.
sp_dir_copy() and sp_dir_move() copy or move folders and their
contents.
As with {fs}, if new_path is an existing folder, each item is placed
inside that folder and keeps its name. Otherwise, new_path is the full
path for the new item and its parent folder must already exist. A new_path
that ends in "/" must be an existing folder.
new_path can be a path relative to the drive that holds the item, or a
SharePoint folder or document library URL. Items can be copied to another
drive or site, but they can only be moved within the same drive.
sp_item_copy( path, new_path, ..., overwrite = FALSE, wait = TRUE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_item_move( path, new_path, ..., overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_dir_copy( path, new_path, ..., overwrite = FALSE, wait = TRUE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_dir_move( path, new_path, ..., drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() )sp_item_copy( path, new_path, ..., overwrite = FALSE, wait = TRUE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_item_move( path, new_path, ..., overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_dir_copy( path, new_path, ..., overwrite = FALSE, wait = TRUE, drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() ) sp_dir_move( path, new_path, ..., drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, call = caller_env() )
path |
A character vector of file or folder paths, or SharePoint file
or folder URLs. A relative path must not include the drive name. |
new_path |
A character vector of new paths, or SharePoint folder or
document library URLs. |
... |
Arguments passed on to
|
overwrite |
If |
wait |
If |
drive_name, drive_id
|
SharePoint drive name or ID. |
drive |
A |
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. |
call |
The execution environment of a currently
running function, e.g. |
Copying is asynchronous
Microsoft Graph copies items in the background. If wait = TRUE (the
default), sp_item_copy() and sp_dir_copy() check the status of each copy
until it is complete, so they can report an error if a copy fails. Large
folders can take a while to copy. If wait = FALSE, the copy may still be
running when the function returns, and a failed copy isn't reported.
Invisibly returns a character vector with the new path of each item, relative to the drive it was copied or moved to.
dir_url <- "<link to SharePoint directory>" if (is_sp_url(dir_url)) { drive <- get_sp_drive(drive_name = dir_url) # Copy a file into an existing folder sp_item_copy("Reports/report.docx", "Archive", drive = drive) # Rename a file sp_item_move( "Reports/report.docx", "Reports/report-2026.docx", drive = drive ) # Copy a folder to a new folder named "Reports-backup" sp_dir_copy("Reports", "Reports-backup", drive = drive) # Move a folder into the folder at a SharePoint URL sp_dir_move("Reports-backup", dir_url, drive = drive) }dir_url <- "<link to SharePoint directory>" if (is_sp_url(dir_url)) { drive <- get_sp_drive(drive_name = dir_url) # Copy a file into an existing folder sp_item_copy("Reports/report.docx", "Archive", drive = drive) # Rename a file sp_item_move( "Reports/report.docx", "Reports/report-2026.docx", drive = drive ) # Copy a folder to a new folder named "Reports-backup" sp_dir_copy("Reports", "Reports-backup", drive = drive) # Move a folder into the folder at a SharePoint URL sp_dir_move("Reports-backup", dir_url, drive = drive) }
get_sp_item_properties() gets the properties of a file or folder, such as
the name, size, and creation date. Set fields = TRUE to also get the
values of the document library columns (fields) for the item. To get the
fields for many items, use get_sp_list() to get the document library as a
list and use list_sp_list_items() or get_sp_list_item() instead.
update_sp_item_properties() renames a file or folder or updates the values
of document library columns for the item. Field values are updated with
update_sp_list_item() using the list for the document library, so the
same field name checks and formatting (e.g. for multi-choice columns) are
used. To move an item to another folder, use sp_item_move() instead.
get_sp_item_properties( path = NULL, item_id = NULL, item_url = NULL, ..., drive = NULL, drive_name = NULL, drive_id = NULL, site_url = NULL, fields = FALSE, as_data_frame = FALSE, call = caller_env() ) update_sp_item_properties( path = NULL, ..., .data = NULL, name = NULL, item_id = NULL, item_url = NULL, item = NULL, check_fields = TRUE, na_fields = c("drop", "replace"), drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, fields = FALSE, as_data_frame = FALSE, call = caller_env() )get_sp_item_properties( path = NULL, item_id = NULL, item_url = NULL, ..., drive = NULL, drive_name = NULL, drive_id = NULL, site_url = NULL, fields = FALSE, as_data_frame = FALSE, call = caller_env() ) update_sp_item_properties( path = NULL, ..., .data = NULL, name = NULL, item_id = NULL, item_url = NULL, item = NULL, check_fields = TRUE, na_fields = c("drop", "replace"), drive_name = NULL, drive_id = NULL, drive = NULL, site_url = NULL, fields = FALSE, as_data_frame = FALSE, call = caller_env() )
path |
A SharePoint file URL or the relative path to a file located in a
SharePoint drive. If input is a relative path, the string should not
include the drive name. If input is a shared file URL, the text "Shared "
is removed from the start of the SharePoint drive name by default. If file
is a document URL, the |
item_id |
A SharePoint item ID passed to the |
item_url |
A SharePoint item URL used to parse the item ID, drive name, and site URL. |
... |
For |
drive |
A |
drive_name, drive_id
|
SharePoint drive name or ID. |
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. |
fields |
If |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
.data |
A named list or a single row data frame with field values to update. Optional. |
name |
A new name for the item. Optional. |
item |
A |
check_fields |
If |
na_fields |
How to handle |
A list of item properties, or a 1 row data frame if
as_data_frame = TRUE. update_sp_item_properties() returns the
properties after the update.
get_sp_item(), get_sp_list_item()
sp_item_url <- "<SharePoint item url>" if (is_sp_url(sp_item_url)) { get_sp_item_properties(sp_item_url, fields = TRUE) update_sp_item_properties( sp_item_url, Title = "Annual report", name = "annual-report-2026.docx" ) }sp_item_url <- "<SharePoint item url>" if (is_sp_url(sp_item_url)) { get_sp_item_properties(sp_item_url, fields = TRUE) update_sp_item_properties( sp_item_url, Title = "Annual report", name = "annual-report-2026.docx" ) }
get_sp_list() is a wrapper for the get_list and list_items methods.
This function is still under development and does not support the URL parsing
used by get_sp_item(). list_sp_lists() returns all lists for a SharePoint
site or drive as a list or data frame. Note, when using filter with
get_sp_list(), names used in the expression must be prefixed with "fields/"
to distinguish them from item metadata.
get_sp_list( list_name = NULL, list_id = NULL, ..., site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, metadata = FALSE, as_data_frame = FALSE, call = caller_env() ) list_sp_lists( site_url = NULL, filter = NULL, n = Inf, ..., site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, as_data_frame = TRUE, call = caller_env() ) get_sp_list_metadata( list_name = NULL, list_id = NULL, sp_list = NULL, ..., keep = c("all", "editable", "external"), sync_fields = FALSE, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, as_data_frame = TRUE, call = caller_env() )get_sp_list( list_name = NULL, list_id = NULL, ..., site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, metadata = FALSE, as_data_frame = FALSE, call = caller_env() ) list_sp_lists( site_url = NULL, filter = NULL, n = Inf, ..., site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, as_data_frame = TRUE, call = caller_env() ) get_sp_list_metadata( list_name = NULL, list_id = NULL, sp_list = NULL, ..., keep = c("all", "editable", "external"), sync_fields = FALSE, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, as_data_frame = TRUE, call = caller_env() )
list_name, list_id
|
SharePoint List name or ID string. |
... |
Arguments passed on to
|
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 |
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
metadata |
If |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
filter |
A string with an OData expression apply as a filter to the results. Learn more in the Microsoft Graph API documentation on using filter query parameters. |
n |
Maximum number of lists, plans, tasks, or other items to return.
Defaults to |
sp_list |
A |
keep |
One of "all" (default), "editable", "external" (non-internal fields). Argument determines if the returned list metadata includes read only columns or hidden columns. |
sync_fields |
If |
A data frame as_data_frame = TRUE or a ms_list object (or list
of ms_list objects) if FALSE.
A SharePoint list definition describes a list and its columns using
Microsoft Graph list and columnDefinition property names. Definitions can
be stored as YAML files, used to create a list with
create_sp_list(definition = ), and compared or synced with an existing
list using compare_sp_list() and sync_sp_list().
read_sp_list_yaml() reads and validates a YAML file.
write_sp_list_yaml() writes a definition or an existing list to a YAML
file.
get_sp_list_definition() creates a definition from an existing list.
as_sp_list_definition() validates a list with the same structure as a
YAML file.
read_sp_list_yaml(path, call = caller_env()) as_sp_list_definition(x, ..., display_name = NULL, call = caller_env()) get_sp_list_definition( sp_list = NULL, ..., keep_defaults = FALSE, read_only = "stable", include_views = FALSE, include_folders = FALSE, call = caller_env() ) write_sp_list_yaml( x, path, ..., merge = TRUE, keep_defaults = FALSE, read_only = "stable", include_views = FALSE, include_folders = FALSE, doc_start = NULL, call = caller_env() )read_sp_list_yaml(path, call = caller_env()) as_sp_list_definition(x, ..., display_name = NULL, call = caller_env()) get_sp_list_definition( sp_list = NULL, ..., keep_defaults = FALSE, read_only = "stable", include_views = FALSE, include_folders = FALSE, call = caller_env() ) write_sp_list_yaml( x, path, ..., merge = TRUE, keep_defaults = FALSE, read_only = "stable", include_views = FALSE, include_folders = FALSE, doc_start = NULL, call = caller_env() )
path |
Path to a YAML file. |
call |
The execution environment of a currently
running function, e.g. |
x |
For |
... |
Must be empty. |
display_name |
List display name. Used by |
sp_list |
A |
keep_defaults |
If |
read_only |
Read-only list properties to include as a reference to
the existing list. One of |
include_views |
If |
include_folders |
If |
merge |
If |
doc_start |
If |
YAML format
# Comments before the first key are kept by write_sp_list_yaml()
---
format_version: 1
displayName: Capital Project
description: Capital projects and their status.
list:
template: genericList
# Read-only properties of an existing list (optional)
id: 5a8b3c4d-0000-0000-0000-000000000000
webUrl: https://example.sharepoint.com/sites/Planning/Lists/CapitalProject
parentReference:
siteId: example.sharepoint.com,1111,2222
custom:
owner: Planning
columns:
- name: Title
displayName: Project Name
required: true
text: {}
- name: ProjectID
displayName: Project ID
description: Project reference ID
required: true
text: {}
- name: Notes
displayName: Project Notes
text:
allowMultipleLines: true
custom:
form_order: 2
- name: Status
choice:
choices:
- Active
- Closed
displayAs: radioButtons
Top-level keys use the Graph list property names:
displayName (required): the list display name. SharePoint sets the
read-only list name (used in the list URL) from the display name when a
list is created. Changing the display name later doesn't change the URL.
columns (required): a sequence of column definitions.
description (optional): the list description.
list (optional): list settings using the
listInfo
property names template (e.g. genericList, the default, or
documentLibrary), hidden, and contentTypesEnabled. The template
can't be changed after a list is created.
format_version (optional): the format version. Only 1 is supported.
custom (optional): a mapping that isn't validated (see below).
Comments and blank lines before the first key are a header that
write_sp_list_yaml() keeps when it updates a file. An optional document
start marker (---) after the header marks where the header ends. Other
comments (including comments between --- and the first key) are lost
when a file is rewritten, so use custom for notes that need to be kept.
A file can only have one YAML document.
Read-only list properties can also be included as a reference to an
existing list: id, name, webUrl, createdDateTime, createdBy,
lastModifiedDateTime, lastModifiedBy, eTag, parentReference,
sharepointIds, and system. These properties are never sent to
SharePoint. compare_sp_list() and sync_sp_list() use
id and parentReference.siteId to get the list if sp_list isn't
supplied, and error if a supplied list has a different id.
create_sp_list() ignores them.
Columns can also include an id as a reference to an existing column.
Columns are always matched by name.
Column keys use the Graph columnDefinition property names:
name (required): the internal column name. The name can't be changed
after a column is created and should avoid names that look like
spreadsheet cell references (e.g. V4). For a list (but not a document
library), the name of a new column can't be longer than 32 characters,
counting each space or special character as 7 (e.g. a space is stored as
_x0020_). SharePoint cuts longer names without an error, so
create_sp_list() and create_sp_list_column() error instead. Display
names can be longer: the column settings page allows up to 255
characters.
displayName, description, required, enforceUniqueValues,
hidden, indexed, readOnly, defaultValue (with value or
formula), and validation (see column_validation()).
Exactly one column type key holding the properties for that type. Use an
empty mapping ({}) for a type with no properties.
A Title column updates the default title column of a genericList list
instead of adding a new column.
Column type keys and properties:
| Type key | Properties |
text |
allowMultipleLines, appendChangesToExistingText, linesForEditing, maxLength, textType |
choice |
allowTextEntry, choices, displayAs |
number |
decimalPlaces, displayAs, maximum, minimum |
dateTime |
displayAs, format |
currency |
locale |
calculated |
formula, outputType, format |
lookup |
listId, columnName, allowMultipleValues, allowUnlimitedLength, primaryLookupColumnId |
personOrGroup |
allowMultipleSelection, chooseFromType, displayAs |
hyperlinkOrPicture |
isPicture |
term |
allowMultipleValues, showFullyQualifiedName |
boolean, geolocation, thumbnail |
none |
Validation rules:
Unknown keys are errors, with a hint for common alternatives (e.g.
label for displayName). Read-only properties (e.g. id) are errors.
Values must match the type and allowed values in the Graph API documentation.
A calculated column requires formula and outputType. format is
only allowed when outputType is dateTime.
A lookup column requires listId and columnName. The listId is
specific to a site.
Column names must be unique. Duplicate display names are a warning since formulas reference columns by display name.
Keys that aren't columnDefinition properties go under custom, either for
the list or for each column. sharepointr doesn't validate custom and
doesn't send it to SharePoint, so it can hold metadata used by other
applications (e.g. form order or app-enforced choices).
Properties that aren't included in a column definition aren't compared or
changed by sync_sp_list(). Removing a property from a file
doesn't reset it to the default value.
List views
An optional views key holds a sequence of list views using the SharePoint
REST API SP.View property names (see list_sp_list_views()):
views:
- Title: Active Projects
DefaultView: true
ViewFields:
- LinkTitle
- ProjectStatus
- Budget
ViewQuery: <Where><Eq><FieldRef Name="ProjectStatus"/><Value Type="Choice">Active</Value></Eq></Where>
RowLimit: 50
CustomFormatter:
additionalRowClass: sp-field-severity--good
Title is required and must be unique. Only one view can set
DefaultView: true.
Other properties are ViewFields (internal column names), ViewQuery
(a CAML query), RowLimit, Paged, Scope, Hidden, MobileView,
MobileDefaultView, and CustomFormatter (view formatting as a YAML
mapping or a JSON string). Id and ServerRelativeUrl can be included
as a reference to an existing view.
A warning is given if a view shows fields that aren't columns in the
definition or built-in fields (e.g. LinkTitle, ID, or Modified).
create_sp_list(definition = ) creates views after creating the columns. A
view titled All Items updates the default view of a new genericList
list. compare_sp_list() and sync_sp_list() compare and update views
only if the definition has a views element. Views are only written by
write_sp_list_yaml() if include_views = TRUE.
Document libraries
A definition with list.template: documentLibrary describes a document
library. Use create_sp_drive() (or create_sp_list()) to create a
library from a definition. The built-in library columns (e.g.
FileLeafRef for the file name or _ExtendedDescription) are left out of
a definition from an existing library and aren't compared unless a
definition includes them. A view titled All Documents updates the
default view of a new library.
An optional folders key holds a sequence of folder paths relative to the
library root. Folders are only allowed for a document library.
list: template: documentLibrary folders: - Contracts - Reports/2026
Separate folders with /. Parent folders are created as needed, so
Reports/2026 also creates Reports.
Paths must be unique. A folder name can't be empty, start or end with a
space, end with a period, or include any of " * : < > ? \ |.
compare_sp_list() and sync_sp_list() add folders that are missing
from the library. Folders are never deleted or renamed.
Folders are only written by write_sp_list_yaml() if include_folders = TRUE. Only the deepest folders of each path are written.
A sp_list_definition object: a list with format_version,
displayName, description, list, any read-only list properties,
custom, columns, views, and folders elements.
write_sp_list_yaml() invisibly returns the definition that was written.
sp_list_definition_table() to convert a definition to a data
frame.
path <- system.file("extdata", "example-list.yaml", package = "sharepointr") definition <- read_sp_list_yaml(path) definition sp_list_definition_table(definition)path <- system.file("extdata", "example-list.yaml", package = "sharepointr") definition <- read_sp_list_yaml(path) definition sp_list_definition_table(definition)
sp_list_definition_table() converts a sp_list_definition object to a
data frame with one row per column. The as.data.frame() method for
sp_list_definition objects uses the same function.
The data frame has list_name, name, displayName, description, and
type columns followed by any other column-level properties, the
properties for each column type, and the custom metadata for each
column. Properties for column types aren't prefixed since each column has a
single column type. Properties with more than one value (e.g. choices)
are list columns and all other columns are simplified to atomic vectors.
sp_list_definition_table(x, custom = TRUE, custom_prefix = NULL) ## S3 method for class 'sp_list_definition' as.data.frame( x, row.names = NULL, optional = FALSE, ..., custom = TRUE, custom_prefix = NULL )sp_list_definition_table(x, custom = TRUE, custom_prefix = NULL) ## S3 method for class 'sp_list_definition' as.data.frame( x, row.names = NULL, optional = FALSE, ..., custom = TRUE, custom_prefix = NULL )
x |
A |
custom |
If |
custom_prefix |
Optional prefix added to the names of |
row.names, optional, ...
|
Ignored. |
A data frame with one row per column.
path <- system.file("extdata", "example-list.yaml", package = "sharepointr") sp_list_definition_table(path)path <- system.file("extdata", "example-list.yaml", package = "sharepointr") sp_list_definition_table(path)
list_sp_list_items() lists sp_list items. This function uses a modified
version of the list_items method for Microsoft365R::ms_list objects that
adds the order_by and order_dir arguments.
list_sp_list_items( list_name = NULL, list_id = NULL, sp_list = NULL, ..., filter = NULL, select = NULL, order_by = NULL, order_dir = "desc", all_metadata = FALSE, as_data_frame = TRUE, col_formatting = c("asis", "date"), display_nm = c("drop", "label", "replace"), select_type = c("asis", "editable", "external"), n = NULL, tz = Sys.timezone(), name_repair = "unique", pagesize = 5000, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() ) get_sp_list_items( list_name = NULL, list_id = NULL, sp_list = NULL, ..., filter = NULL, select = NULL, order_by = NULL, order_dir = "desc", all_metadata = FALSE, as_data_frame = TRUE, col_formatting = c("asis", "date"), display_nm = c("drop", "label", "replace"), n = NULL, tz = Sys.timezone(), name_repair = "unique", pagesize = 5000, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() ) get_sp_list_item( id, list_name = NULL, list_id = NULL, sp_list = NULL, ..., site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() )list_sp_list_items( list_name = NULL, list_id = NULL, sp_list = NULL, ..., filter = NULL, select = NULL, order_by = NULL, order_dir = "desc", all_metadata = FALSE, as_data_frame = TRUE, col_formatting = c("asis", "date"), display_nm = c("drop", "label", "replace"), select_type = c("asis", "editable", "external"), n = NULL, tz = Sys.timezone(), name_repair = "unique", pagesize = 5000, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() ) get_sp_list_items( list_name = NULL, list_id = NULL, sp_list = NULL, ..., filter = NULL, select = NULL, order_by = NULL, order_dir = "desc", all_metadata = FALSE, as_data_frame = TRUE, col_formatting = c("asis", "date"), display_nm = c("drop", "label", "replace"), n = NULL, tz = Sys.timezone(), name_repair = "unique", pagesize = 5000, site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() ) get_sp_list_item( id, list_name = NULL, list_id = NULL, sp_list = NULL, ..., site_url = NULL, site = NULL, drive_name = NULL, drive_id = NULL, drive = NULL, call = caller_env() )
list_name, list_id
|
SharePoint List name or ID string. |
sp_list |
A |
... |
Arguments passed on to
|
filter |
A string with an OData expression apply as a filter to the results. Learn more in the Microsoft Graph API documentation on using filter query parameters. |
select |
A character vector of column names to include in the returned
data frame of list items. If |
order_by |
Optional. Field name to order by. |
order_dir |
Direction to order results if |
all_metadata |
If |
as_data_frame |
If |
col_formatting |
"asis" (default) or "date". If "date", use the list column metadata and convert date columns to Date class and datetime columns to POSIXct class vectors (latter is not yet tested). |
display_nm |
Option of "drop" (default), "label", or "replace". If
"drop", display names are not accessed or used. If "label", display names
are used to label matching columns in the returned data frame. If
"replace", display names replace column names in the returned data frame.
When working with the last option, the |
select_type |
Type of columns to select. Ignored if |
n |
Maximum number of lists, plans, tasks, or other items to return.
Defaults to |
tz |
Time zone to use in reformatting date/time columns if
|
name_repair |
Passed to repair argument of |
pagesize |
Number of list items to return. Reduce from default of 5000 is experiencing timeouts. |
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 |
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive |
A |
call |
The execution environment of a currently
running function, e.g. |
id |
Required. A SharePoint list item ID typically an integer for the record number starting from 1 with the first record. |
For list_sp_list_items() and get_sp_list_items(), a data
frame of list items if as_data_frame = TRUE (default), or a list of
item fields otherwise. For get_sp_list_item(), a ms_list_item
object.
get_sp_plan() returns a single ms_plan object using the get_plan
method. list_sp_plans() returns a data frame with plan properties or a list
of ms_plan objects.
get_sp_plan( plan_title = NULL, plan_id = NULL, ..., site = NULL, site_url = NULL, as_data_frame = FALSE, call = caller_env() ) list_sp_plans( ..., filter = NULL, n = NULL, site = NULL, as_data_frame = TRUE, call = caller_env() )get_sp_plan( plan_title = NULL, plan_id = NULL, ..., site = NULL, site_url = NULL, as_data_frame = FALSE, call = caller_env() ) list_sp_plans( ..., filter = NULL, n = NULL, site = NULL, as_data_frame = TRUE, call = caller_env() )
plan_title, plan_id
|
Planner title or ID. Exactly one of the two arguments must be supplied. |
... |
Additional arguments passed to |
site |
A |
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. |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
filter |
A string with an OData expression apply as a filter to the results. Learn more in the Microsoft Graph API documentation on using filter query parameters. |
n |
Maximum number of lists, plans, tasks, or other items to return.
Defaults to |
For get_sp_plan(), a ms_plan class object or a 1 row data frame
with a "ms_plan" column.
For list_sp_plans(), A list of ms_plan class objects or a data
frame with a list column named "ms_plan".
list_sp_plan_buckets() lists the buckets for a specified plan using the
list_buckets method.
list_sp_plan_buckets( plan_title = NULL, plan_id = NULL, ..., filter = NULL, n = NULL, plan = NULL, as_data_frame = TRUE, call = caller_env() )list_sp_plan_buckets( plan_title = NULL, plan_id = NULL, ..., filter = NULL, n = NULL, plan = NULL, as_data_frame = TRUE, call = caller_env() )
plan_title, plan_id
|
Planner title or ID. Exactly one of the two arguments must be supplied. |
... |
Additional arguments passed to |
filter |
A string with an OData expression apply as a filter to the results. Learn more in the Microsoft Graph API documentation on using filter query parameters. |
n |
Maximum number of lists, plans, tasks, or other items to return.
Defaults to |
plan |
A |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
For list_sp_plan_buckets(), a list of ms_plan_bucket class
objects or a data frame with a list column named "ms_plan_task".
get_sp_site() is a wrapper for Microsoft365R::get_sharepoint_site() and
returns a ms_site object. cache_sp_site() allows you to cache a default
SharePoint site for use by other functions. Users seeking to access a
SharePoint subsite must provide the site_id instead of a site_url or
site_name value. You can see available subsite ID values by using the
list_subsites() method for Microsoft365R::ms_site objects.
get_sp_site( site_url = NULL, site_name = NULL, site_id = NULL, ..., cache = getOption("sharepointr.cache", FALSE), refresh = getOption("sharepointr.refresh", TRUE), overwrite = FALSE, cache_file = NULL, call = caller_env() ) cache_sp_site( ..., site = NULL, cache_file = NULL, cache_dir = NULL, overwrite = FALSE, call = caller_env() )get_sp_site( site_url = NULL, site_name = NULL, site_id = NULL, ..., cache = getOption("sharepointr.cache", FALSE), refresh = getOption("sharepointr.refresh", TRUE), overwrite = FALSE, cache_file = NULL, call = caller_env() ) cache_sp_site( ..., site = NULL, cache_file = NULL, cache_dir = NULL, overwrite = FALSE, call = caller_env() )
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_name, site_id
|
Site name or ID of the SharePoint site as an
alternative to the SharePoint site URL. Exactly one of |
... |
Arguments passed on to
|
cache |
If |
refresh |
If |
overwrite |
If |
cache_file |
File name for cached drive or site. Default |
call |
The execution environment of a currently
running function, e.g. |
site |
A |
cache_dir |
Cache directory. By default, uses an option
named "sharepointr.cache_dir". If "sharepointr.cache_dir" is not set, the
cache directory is set to |
For get_sp_site(), a ms_site object. For cache_sp_site(),
invisibly returns NULL.
get_sp_task() gets an individual planner task using the get_task method.
list_sp_tasks() lists the tasks for a specified plan using the list_tasks
method.
get_sp_task( task_title = NULL, task_id = NULL, ..., plan_title = NULL, plan_id = NULL, plan = NULL, as_data_frame = FALSE, call = caller_env() ) list_sp_tasks( plan_title = NULL, plan_id = NULL, ..., filter = NULL, n = NULL, plan = NULL, as_data_frame = TRUE, call = caller_env() )get_sp_task( task_title = NULL, task_id = NULL, ..., plan_title = NULL, plan_id = NULL, plan = NULL, as_data_frame = FALSE, call = caller_env() ) list_sp_tasks( plan_title = NULL, plan_id = NULL, ..., filter = NULL, n = NULL, plan = NULL, as_data_frame = TRUE, call = caller_env() )
task_title, task_id
|
Planner task title and id. Exactly one of
|
... |
Additional arguments passed to |
plan_title, plan_id
|
Planner title or ID. Exactly one of the two arguments must be supplied. |
plan |
A |
as_data_frame |
If |
call |
The execution environment of a currently
running function, e.g. |
filter |
A string with an OData expression apply as a filter to the results. Learn more in the Microsoft Graph API documentation on using filter query parameters. |
n |
Maximum number of lists, plans, tasks, or other items to return.
Defaults to |
For list_sp_tasks(), a list of ms_plan_task class objects or a
data frame with a list column named "ms_plan_task".
update_sp_drive() updates the display name or description of a document
library. Changing the display name changes the drive name but not the
library URL.
delete_sp_drive() deletes a document library and all of its files and
folders. It requires confirmation by default and can't delete the default
document library of a site (usually named "Documents").
Both functions get the library's list from the drive and use
update_sp_list() or delete_sp_list().
update_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, drive = NULL, display_name = NULL, description = NULL, ..., properties = FALSE, site_url = NULL, site = NULL, call = caller_env() ) delete_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, drive = NULL, confirm = TRUE, ..., site_url = NULL, site = NULL, call = caller_env() )update_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, drive = NULL, display_name = NULL, description = NULL, ..., properties = FALSE, site_url = NULL, site = NULL, call = caller_env() ) delete_sp_drive( drive_name = NULL, drive_id = NULL, drive_url = NULL, drive = NULL, confirm = TRUE, ..., site_url = NULL, site = NULL, call = caller_env() )
drive_name, drive_id
|
SharePoint Drive name or ID passed to |
drive_url |
A SharePoint Drive URL to parse for a Drive name and other
information. If |
drive |
A |
display_name |
New display name for the library. Optional. |
description |
New description for the library. Optional. |
... |
Additional parameters passed to |
properties |
For |
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 |
call |
The execution environment of a currently
running function, e.g. |
confirm |
If |
For update_sp_drive(), the updated ms_drive object or its
properties if properties = TRUE. For delete_sp_drive(), invisibly
returns NULL.
## Not run: drive <- update_sp_drive( "Project Files", description = "Files for active projects", site_url = "<SharePoint site url>" ) delete_sp_drive(drive = drive) ## End(Not run)## Not run: drive <- update_sp_drive( "Project Files", description = "Files for active projects", site_url = "<SharePoint site url>" ) delete_sp_drive(drive = drive) ## End(Not run)
upload_sp_item() wraps the upload_folder and upload_file method for
ms_drive objects. upload_sp_items() uploads multiple files or folders.
If {carrier} and {mirai} are installed and mirai::daemons() are set,
upload_sp_items() uploads files in parallel (folders are always uploaded
one at a time).
upload_sp_item( file = NULL, dest = NULL, ..., src = NULL, overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, blocksize = 327680000, recursive = FALSE, parallel = FALSE, call = caller_env() ) upload_sp_items( file = NULL, dest, ..., src = NULL, overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, blocksize = 327680000, recursive = FALSE, parallel = FALSE, call = caller_env() )upload_sp_item( file = NULL, dest = NULL, ..., src = NULL, overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, blocksize = 327680000, recursive = FALSE, parallel = FALSE, call = caller_env() ) upload_sp_items( file = NULL, dest, ..., src = NULL, overwrite = FALSE, drive_name = NULL, drive_id = NULL, drive = NULL, blocksize = 327680000, recursive = FALSE, parallel = FALSE, call = caller_env() )
file |
Path for file or directory to upload. Optional if |
dest |
Destination on SharePoint for file to upload. Must be a
|
... |
Additional parameters passed to |
src |
Data source path passed to |
overwrite |
If |
drive_name, drive_id
|
SharePoint drive name or ID. |
drive |
A |
blocksize, recursive, parallel
|
Additional parameters passed to
|
call |
The execution environment of a currently
running function, e.g. |
Invisibly returns the destination path (dest) for the uploaded
file or directory.