I have a case where I need to update a property on a document immediately after it is published. The idea is that on a publish event the unpublished value will be published and then a new unpublished value will instantly be created.
However it seems that calling ContentService.Save() on a document in the Published event cancels the publish on that node. This behaviour is surprising, is there a way around this? I would expect the publish to continue and a new (draft) version of the document to be created chronologically after the published one.
So to complement my expected example earlier, here is the actual behaviour:
I don't know of a real way around this, but I eventually came up with a workaround which is a custom property editor for this property. Whenever a user edits or publishes a content node the property editor's controller calls an API which checks if the published value == the draft value, and if so it bumps the draft value. It's not particularly pretty but it works reliably.
Saving a document from within its Published event
Hi,
I have a case where I need to update a property on a document immediately after it is published. The idea is that on a publish event the unpublished value will be published and then a new unpublished value will instantly be created.
For example: (Expected)
I'm using the ContentService.Published event to do this: (Note that this isn't my actual use-case, this is a Minimal, Complete and Verifiable example)
However it seems that calling ContentService.Save() on a document in the Published event cancels the publish on that node. This behaviour is surprising, is there a way around this? I would expect the publish to continue and a new (draft) version of the document to be created chronologically after the published one.
So to complement my expected example earlier, here is the actual behaviour:
Thanks,
Josh
I don't know of a real way around this, but I eventually came up with a workaround which is a custom property editor for this property. Whenever a user edits or publishes a content node the property editor's controller calls an API which checks if the published value == the draft value, and if so it bumps the draft value. It's not particularly pretty but it works reliably.
is working on a reply...