gpt4 book ai didi

metadata - Tridion CoreService 创建组件缺少元数据

转载 作者:行者123 更新时间:2023-12-02 19:34:09 26 4
gpt4 key购买 nike

我遇到异常 = {"无法找到 uuid:5708986b-390f-4728-b0c7-b49bd3d8f407:元数据。"}

schemaId = UpdatePubId(schemaId, containerId);
SchemaData schemaData = (SchemaData)client.Read(schemaId, null);
string xml = string.Format("<{0} xmlns=\"{1}\">{2}</{0}>", schemaData.RootElementName, schemaData.NamespaceUri, fields);

ComponentData componentData = new ComponentData
{
Content = xml,
ComponentType = ComponentType.Normal,
Title = title,
Schema = new LinkToSchemaData { IdRef = schemaId },
LocationInfo = new LocationInfo { OrganizationalItem = new LinkToOrganizationalItemData { IdRef = containerId } },
Id = "tcm:0-0-0",
MetadataSchema = schemaData.MetadataSchema,
Metadata = schemaData.Metadata
};

try
{
componentData = client.Save(componentData, new ReadOptions()) as ComponentData;
componentData = client.CheckIn(componentData.Id, new ReadOptions()) as ComponentData;
message.Set("Component", title + ", successfully");
}
catch (Exception exception)
{
message.Set("Component", exception.Message);
}

感谢 Tridion 专家

最佳答案

您的路径正确,但错误表明您尚未为尝试创建的组件提供元数据字段。

此行不正确:

Metadata = schemaData.Metadata

它应该非常像您创建内容字段的地方:

Metadata = String.Format("<Metadata xmlns=\"{0}\">{1}</Metadata>",schemaData.NamespaceUri, "YOUR METADATA XML")

关于metadata - Tridion CoreService 创建组件缺少元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com