Skip to content

Expose op to update custom metadata fields on items #34

@jonocarroll

Description

@jonocarroll

I am trying to update some custom metadata of a sharepoint item (additional columns added, not just "name") with this package. I am able to achieve this via the mgc cli with e.g.

mgc sites lists items fields patch --list-id $listID --site-id $siteID --list-item-id 5 --body '{"metadataValue": "123"}'

With AzureGraph, following this workflow:

gr <- get_graph_login()
site <- gr$get_sharepoint_site(sp_url)
lists <- site$get_lists()[[1]]
item <- lists$get_item(5)
item$update("metadataValue" = "123")

the path that is constructed does not include the "fields" path. It appears that the op argument to do_operation() would be where this could/should be set, but this is not exposed to the outer update() function

AzureGraph/R/ms_object.R

Lines 81 to 86 in 983aaaa

update=function(...)
{
self$do_operation(body=list(...), encode="json", http_verb="PATCH")
self$properties <- self$do_operation()
self
},

...

AzureGraph/R/ms_object.R

Lines 113 to 117 in 983aaaa

do_operation=function(op="", ...)
{
op <- construct_path(private$api_type, self$properties$id, op)
call_graph_endpoint(self$token, op, ...)
},

Could this be modified to update(op="", ...) (or some other equivalent approach)? It is difficult to inject this since the class is R6, but my workaround for the moment is

field_update <- function(obj, ...) {
  obj$do_operation(op = "fields", body = list(...), encode = "json", http_verb = "PATCH")
}
field_update(item, "metadataValue" = "123")

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