Azure / Azure/Microsoft365R

Uploading to list that has multiple choices selected in a column

Open
#227 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
368
Forks
58
Avg merge
1h 42m
Merged PRs (30d)
4

Description

I am trying to upload items from a survey to a Sharepoint list. I collapsed multiple columns into a single column. On the Sharepoint list, this column allows for multiple choices to be selected. However, I can't upload the list from R to Sharepoint because of the multiple choices column. I found this information in the Microsoft help site, but I am unsure of how to make the column type in R conform to the column type of the Sharepoint list.

```{
"fields": {
"******@odata.type": "Collection(Edm.String)",
"choice_checkboxes":["cb1","cb2"]
}
}
```

Is there a way of translating the JSON data type in R or another way of making it so I can upload a list that has a column with multiple choices to my Sharepoint list from R? Here is a minimal reproducible example:

```
df <- tibble(astronomy = c(NA,NA,"Astronomy"),
biology = c("Biology",NA,"Biology"),
chemistry = c("Chemistry","Chemistry","Chemistry"))

df <- df |>
unite(discipline,astronomy:chemistry,sep=";",na.rm=TRUE)

## The below was my attempt to make the column conform to the list column structure
disc <- list()
disc[[1]] <- df$discipline
for(i in 1:nrow(df)){
df$discipline[i] <- disc[[1]][i]
}

df <- df |>
mutate(discipline = str_split(discipline,";"))

lst$bulk_import(df)
```

Contributor guide

Open the contributing guide

Research direction

Start at the lst$bulk_import(df) entry point and compare the minimal reproducible example with the SharePoint multi-choice payload shown in the issue. Trace how the discipline column is serialized, then verify that the example uploads successfully to a list column allowing multiple choices.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.