Skip to content

Uploading to list that has multiple choices selected in a column #227

@cswan5

Description

@cswan5

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions