var contentService = ApplicationContext.Current.Services.ContentService;
var contentNode = contentService.CreateContent(name,parentId, docTypeAlias, 0);
contentNode.SetValue("productCode", productCode);
contentNode.SetValue("currencyCode", currencyCode);
//Get id of created content
int nodeId = contentNode.Id;
contentService.SaveAndPublish(contentNode);
v6 CreateContent method return values
Hi,
Does anyone know if this method can return the node id of the created content?
I've checked the documentation here: http://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService
Thanks
Damien
I believe these methods return an instance of the created content, so from the return object you should be able to just check it's Id property.
Andy
Hi Andy,
Thanks it did indeed.
Sorry I was quick to assume this worked when all i get returned is 0 for the nodeId ?
Ok, anyone else who struggles with this there is a non documented method:
contentService.CreateContentWithIdentity
This works a treat.
is working on a reply...