【问题标题】:How to get Tridion item ID after created using Core Service使用核心服务创建后如何获取 Tridion 项目 ID
【发布时间】:2012-03-07 11:24:40
【问题描述】:

我正在使用 post 中的核心服务创建一个新项目。但是,新创建的项目的 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

【问题讨论】:

    标签: tridion


    【解决方案1】:

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

    newComponent = (ComponentData) client.Create(newComponent, new ReadOptions());
    

    【讨论】:

    • 我更喜欢这个解决方案,因为它使用 .Create 方法,我不需要创建额外的对象来保存我保存的数据。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2012-03-24
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 1970-01-01
      • 2012-05-13
      • 2013-01-05
      • 2012-03-11
      相关资源
      最近更新 更多