2012-03-07 34 views
4

我正在使用核心服务在此创建一个新项目post。但是,新创建的项目的URI是tcm:0-0-0,而不是实际的TCM URI。 Title属性是正确的(而不是New Component),但WebDav路径返回'New Component'。如何使用核心服务创建后创建Tridion项目ID

什么是获得我新创建的项目的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

Create方法的第二个参数是ReadOptions。它们用于指定项目将如何回读。在你的例子中,你将它设置为null,这意味着你不会读回它。你应该做的是设置ReadOptions并指定项目回读给一个变量,就像这样:

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

我喜欢这个解决方案,因为它使用的.Create方法,我也不需要创建一个额外的对象来保存我保存数据。 – robrtc 2012-03-07 12:59:12

相关问题