I use the Published event in Umbraco ContentService, and everything is working fine when saving/publish an existing node. But if I create a new node and save/publish it, I can't get the published node as an DynamicNode (n is null) (I need to get the whole structure of the published node)
void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e) { foreach (var node in e.PublishedEntities) { DynamicNode n = new DynamicNode(node.Id); // Works with existing nodes, but not when creating a new one. (the new id exists in node.Id)
Hi, could you expalin a bit more what you are trying to do? i am confused. is the problem you cannot get your node as DynamicNode after createing a new node using the content service
Yes, that's the problem, but I solved it by using the ParentId of the created/published node to create a DynamicNode, so I could use Linq and get some properties from the a level 2 node.
Does it have something to do with the cache not updated before the Published event (DynamicNode uses the cache).
Yea you have got it its the cache not being updated. You can use UpdateCache() method (i think thats the name). There is a bug in one of the version but dont know which this is :).
Umbraco 7.1 and ContentService.Published
I use the Published event in Umbraco ContentService, and everything is working fine when saving/publish an existing node.
But if I create a new node and save/publish it, I can't get the published node as an DynamicNode (n is null)
(I need to get the whole structure of the published node)
void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
foreach (var node in e.PublishedEntities)
{
DynamicNode n = new DynamicNode(node.Id); // Works with existing nodes, but not when creating a new one. (the new id exists in node.Id)
Hi, could you expalin a bit more what you are trying to do? i am confused. is the problem you cannot get your node as DynamicNode after createing a new node using the content service
Yes, that's the problem, but I solved it by using the ParentId of the created/published node to create a DynamicNode, so I could use Linq and get some properties from the a level 2 node.
Does it have something to do with the cache not updated before the Published event (DynamicNode uses the cache).
/Jonas
Yea you have got it its the cache not being updated. You can use UpdateCache() method (i think thats the name). There is a bug in one of the version but dont know which this is :).
Charlie :)
is working on a reply...