4

我正在这篇文章中使用核心服务创建一个新项目。但是,新创建的项目的 URI 是 tcm:0-0-0 而不是实际的 TCM URI。Title 属性是正确的(而不是新组件),但 WebDav 路径在 .

获取新创建项目的 URI 的最佳方法是什么?

client.Create(newComponent, null);
string newItemUri = newComponent.Id; // returns tcm:0-0-0
string webDavUrl = newComponent.LocationInfo.WebDavUrl;  // returns New%20Component
string title = newComponent.Title;  // correct
4

2 回答 2

4

在http://blog.building-blocks.com/uploading-images-using-the-core-service-in-sdl-tridion-2011查看 Ryan 的代码。他使用 client.Save 来获取保存的组件,他可以从中访问 ID。

于 2012-03-07T11:49:29.903 回答
4

Create 方法的第二个参数是 ReadOptions。它们用于指定如何回读项目。在您的示例中,您将其设置为 null,这意味着您不会读回它。您应该做的是设置 ReadOptions 并将项目读回分配给变量,如下所示:

newComponent = (ComponentData) client.Create(newComponent, new ReadOptions());
于 2012-03-07T11:51:20.513 回答