使用核心服务创建后如何获取Tridion项目ID

使用核心服务创建后如何获取Tridion项目ID,tridion,Tridion,我正在使用本文中的核心服务创建一个新项目。但是,新创建项的URI是tcm:0-0-0,而不是实际的tcm URI。Title属性是正确的(不是新组件),但WebDav路径在返回时返回“New Component” 获取新创建项目的URI的最佳方法是什么 client.Create(newComponent, null); string newItemUri = newComponent.Id; // returns tcm:0-0-0 string webDavUrl = newComponen

我正在使用本文中的核心服务创建一个新项目。但是,新创建项的URI是tcm:0-0-0,而不是实际的tcm URI。Title属性是正确的(不是新组件),但WebDav路径在返回时返回“New Component”

获取新创建项目的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

查看Ryan的密码。他使用client.Save获取保存的组件,从中可以访问ID。

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

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

我更喜欢此解决方案,因为它使用.Create方法,并且我不需要创建额外的对象来保存保存的数据。