Problem with updating Managed Metadata column along with other column types to drive item in sharepoint using Graph API c#

huangapple go评论60阅读模式
英文:

Problem with updating Managed Metadata column along with other column types to drive item in sharepoint using Graph API c#

问题

我遇到这样的情况,当我尝试使用Graph API更新DriveItem的元数据时,它并没有更新我指定的所有字段。

以下是我尝试处理的额外数据列。

fieldvalueset = new FieldValueSet
{
    AdditionalData = new Dictionary<string, object>()
    {
        {"aeaaa8de8b8c4df99f251ec41b221cb5",termreferences},
        {"c9e01cf2707746118721ab0ba03d23a7", directortermreferences},
        {"fec9fa55dcc34d41a5eae8927e5fb90d",SectionTermRef },
        {"Document_x0020_Type","BTOR" },
        {"Prepared_x0020_ByLookupId",userLookupId },
        {"State","Draft" }
    }
};

问题是:

  • 当我一次性填充所有字段时,只有术语引用(1、2、3)被填充,其他字段都被留空。
  • 当我尝试填充2、4、5、6时,只有2被填充。
  • 当我尝试将单一查找填充到术语引用时,它们会从文件中擦除非查找元数据。

更新代码是:

var updatefield= await graph
    .Sites[siteId]
    .Drives[DriveId]
    .Items[Driveitem.Id]
    .ListItem
    .Fields
    .Request()
    .UpdateAsync(fieldvalueset);

术语引用的格式如下:

//对于单一术语引用
termreferences = "-1;#" + term.Label + "|" + term.TermGuid;
//在多选术语引用的循环内
if(termreferences=="")
{
    termreferences = "-1;#" + term.Label + "|" + term.TermGuid;
}
else
{
    termreferences= termreferences+";#"+ "-1;#" + term.Label + "|" + term.TermGuid;
}

我尝试了一切,但似乎无法弄清楚为什么它会删除非术语字段。

有人知道解决方法吗?

英文:

Im experiencing a situation where when i try to update metadata to a driveitem using graph api, it doesnt update all the fields i tell it to.

this is the field additional data column im trying to work with.

fieldvalueset = new FieldValueSet
                    {
                        AdditionalData = new Dictionary<string, object>()
                                    {
                                        {"aeaaa8de8b8c4df99f251ec41b221cb5",termreferences},
                                        {"c9e01cf2707746118721ab0ba03d23a7", directortermreferences},
                                        {"fec9fa55dcc34d41a5eae8927e5fb90d",SectionTermRef },
                                        {"Document_x0020_Type","BTOR" },
                                        {"Prepared_x0020_ByLookupId",userLookupId },
                                        {"State","Draft" }
                                    }
                    };

now the first three are metadata lookup fields and the termreference are in the required format to deal with those types of metadata.

1.termreference is a multiselect lookup
2.directoratetermreference is a single lookup
3.sectiontermref is a single lookup
4.document_x0020_type is a choice option
5.prepared_x0020_bylookupid is a person and group type
6.state is a choice option

what im experiencing is very strange.

  1. when i populate columns 1,4,5,6 they all populate correctly.
  2. when i try to populate all at once, only the termreferences ( 1,2,3 ) populate , all the others are left blank
  3. when i try to populate 2,4,5,6 only 2 is populated

for some reason when i try to populate the single lookups to term references, they somehow erase the non-lookup metadata from the file.

the update code i have is

var updatefield= await graph
                      .Sites[siteId]
                      .Drives[DriveId]
                      .Items[Driveitem.Id]
                      .ListItem
                      .Fields
                      .Request()
                      .UpdateAsync(fieldvalueset);

this is the format of the term references

//for single termreference 
termreferences = "-1;#" + term.Label + "|" + term.TermGuid;
//within a loop for multichoice term reference
 if(termreferences=="")
                        {
                            termreferences = "-1;#" + term.Label + "|" + term.TermGuid;
                        }
                        else
                        {
                            termreferences= termreferences+";#"+ "-1;#" + term.Label + "|" + term.TermGuid;
                        }

Iv tried everything and cant seem to figure out why its removing the non term fields.
I even tried updating the term fields first then the other after, but there doesnt seem to be an append function. UpdateAsync removes previous metadata when you do another call to it.

anyone know the workaround to this ?

答案1

得分: 0

单一受控元数据字段填充其他元数据似乎存在问题。

将单一输入字段转换为多输入字段,它们与其他元数据标签一起正常工作。

解决了我当前的问题,但无法确定单一输入受控元数据更新的问题所在。

英文:

Seems to be a problem with populating the Single managed metadata fields with other metadata.

Converted the single input fields to multi-input and they worked fine along with the other metadata tags.

Solved my immediate problem, but was not able to identify what the problem was with single input managed metadata updating.

huangapple
  • 本文由 发表于 2023年4月13日 20:20:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005364.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定