1

I tried to update a Person filed named "CurrentAssignedTo" like so:

var fieldValueSet = new FieldValueSet                {
    AdditionalData = new Dictionary<string, object>(){
    {"CurrentQueue", "Editor"},{"JobStatus", $"Questions answered by {comm.User}"}, 
    {"CurrentAssignedToId", comm.Editor.Id.ToString()}        }                };

But the line:

await graphClient.Sites[site.Id].Lists[list.Id].Items[items[0].Id].Fields.Request().UpdateAsync(fieldValueSet);

Errors on the name "CurrentAssignedToId" (Like I used to do with SharePoint API)

But if I use "CurrentAssignedTo" it does not update the person field.

Anyone knows how to make it work? Thanks

Shiva Keshav Varma
  • 3,398
  • 2
  • 9
  • 13
Ofer Gal
  • 707
  • 1
  • 10
  • 32
  • Duplicate: https://stackoverflow.com/questions/42701107/how-do-i-update-the-value-of-person-or-group-columns-in-sharepoint-lists-using-t/59448206#59448206 – Marc Jun 15 '20 at 08:19

1 Answers1

1

In Graph API, should append LookupId after person field name like below:

Update: the person field value should be int value not string value.

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

    var fieldValueSet = new FieldValueSet
    {
        AdditionalData = new Dictionary<string, object>()
        {
            {"Title", "Title123"},
            {"CurrentAssignedToLookupId", 15}
        }
    };

    var result = graphClient.Sites["siteId"].Lists["ListId"].Items["ItemId"].Fields.Request().UpdateAsync(fieldValueSet);

enter image description here

Jerry
  • 3,480
  • 1
  • 10
  • 12
  • In my code , comm.Editor.Id.ToString() =="6" and still no work – Ofer Gal Jun 15 '20 at 11:47
  • @OferGal, the issue is less related with the value, you are using the wrong property name change CurrentAssignedToId to CurrentAssignedToLookupId – Jerry Jun 15 '20 at 13:14
  • Updated the post, change value to int type rather than string type. – Jerry Jun 16 '20 at 09:47
  • So what was for SharePoint API ***Id is now ***LookupId in Graph? Does MSFT want to make everything difficult on purpose? :-) – Ofer Gal Jun 16 '20 at 15:50
  • @OferGal, this is actually CurrentAssignedToLookupId in Graph API, you can do a GET request in Graph Explorer with this endpoint:https://graph.microsoft.com/v1.0/sites/siteId/Lists/ListId/items/itemid Does MSFT want to make everything difficult on purpose? :-) No, this is some difference in Graph API :-) – Jerry Jun 17 '20 at 00:40
  • 1
    @OferGal, please try the suggestion in the post,if you updates, please share the info. :) – Jerry Jun 17 '20 at 00:43
  • Yes The {personField}LookupId works fine! Thank you @jerry_MSFT – Ofer Gal Jun 20 '20 at 15:13
  • Hi Ofer, Glad to hear it's working now. You could accept this reply as answer so that it will be useful to other in the forum who have similiar question. Best Regard :) – Jerry Jun 22 '20 at 00:43
  • 1
    I can see how to flag it as bad But ignorant me, I do not see how to flag it as a good answer. (new question :-) ) Got it Forget me :-) – Ofer Gal Jun 22 '20 at 21:36
  • You can edit some words in original question and then I will upvote the question for you :) – Jerry Jun 23 '20 at 01:34