更新列表项多个查找值字段Microsoft Graph

问题描述 投票:0回答:1

我正在尝试更新列表项的多重查找值字段。

我尝试了以下代码:

List < QueryOption > options = new List < QueryOption > {
    new QueryOption("$expand", "listitem")
};
//get drive item with list item
var driveItem = graphClient.Sites[IdGestDoc].Drive.Items[itemResult.Id].Request(options).GetAsync().Result;
var fieldValueSet = new FieldValueSet {
    AdditionalData = new Dictionary < string,
    object > {
        {
            "[email protected]",
            "Collection(Edm.String)"
        }, {
            "Theme_fonctionnel", ThemeFonctionnel.ToArray()
        } //ThemeFonctionnel is a List<string> => lookupid
    }
};
await graphClient.Sites[IdGestDoc].Lists["Documents"].Items[driveItem.ListItem.Id].Fields.Request().UpdateAsync(fieldValueSet);

但是此代码不起作用,我找不到我所缺少的东西。任何帮助将不胜感激!

c# api microsoft-graph sharepoint-online
1个回答
1
投票

要设置查阅字段,您需要通过传递属性名称和附加的'LookupId'来设置属性:

        string propertyName = "Theme_fonctionnel";

        var fieldValueSet = new FieldValueSet();

        var propertyValuesArray = options.ToArray();

        var attributes = new Dictionary<string, object>();

        //first, we need to specify the input data type
        string oDataTypeInfoPropertyName = propertyName + "[email protected]";
        string oDataDataType = "Collection(Edm.String)";
        attributes.Add(oDataTypeInfoPropertyName, oDataDataType);

        //next, we need to pass the values as an array
        string newPropertyName = propertyName + "LookupId";
        attributes.Add(newPropertyName, propertyValuesArray);

        fieldValueSet.AdditionalData = attributes;
© www.soinside.com 2019 - 2024. All rights reserved.