updating property in AfterPublish does not update property in editor UI - v4.11.1
I am experiencing an issue in v 4.11.1 when modifying a property in the AfterPublish event. If the property is empty I give it a default value (this field is a guid/unique id for saving to an external destination) and I save the new item to the external destination. When the publish finishes, the editor (ui) is not updated with the new value of the property I just set in AfterPublish. I have tried using umbraco.library.UpdateDocumentCache() but that has no effect.
I would like to have the value of the property assigned during AfterPublish() show up in the UI when the publish is complete.
An alternative would be to somehow force the reload of the editor page (but we are diving way too far into customization here, IMHO).
What ends up happening is that when the user publishes the item again from that same page (without clicking the item in the tree to reload the page, etc...imagine they made a typo or forgot something) the AfterSave() event handler has no value in the property and it generats a new guid/unique and publishes again to the external source... now I have two of the same item in the external destination. This will happen for as many times as someone clicks publish without reloading the page. The result is that there are as many items in my external destination as there have been publishes without reloading the editor ui.
Can anyone recommend a fix or where I might look to get this working as expected?
It's almost like the umbraco editor is doing everything client side (via Ajax or something) and not reloading the editor page at all. This was working as expected in 4.9.x if I remember correctly.
This is also happening with Media.AfterSave()...
Things I have tried: umbraco.library.UpdateDocumentCache(<docId>) in the AfterSave, calling Save() on the document, setting the id in the BeforeSave() event (using umbraco.library.UpdateDocumentCache(<docId>) there actually fails)
Hi Brice, Any resolution on this issue? I am experiencing the same thing and have not solved the issue of having a GUID/key being generated and having the UI updated after the publish event.
Steps to reproduce:
Publish: field is updated and saved in a custom event handler.
Result:
Read-Only Umbraco UI field remains empty after publish.
Reload node from tree. The field has the proper generated content.
Simply put; how do we reload the Umbraco UI for the editors after a publish event is complete to ensure that the content generated is available to the user?
Keep in mind that you should not abort the thread until the end of your operation in Umbraco. Here is a good post of pitfalls to avoid when calling a the redirect.
updating property in AfterPublish does not update property in editor UI - v4.11.1
I am experiencing an issue in v 4.11.1 when modifying a property in the AfterPublish event. If the property is empty I give it a default value (this field is a guid/unique id for saving to an external destination) and I save the new item to the external destination. When the publish finishes, the editor (ui) is not updated with the new value of the property I just set in AfterPublish. I have tried using umbraco.library.UpdateDocumentCache() but that has no effect.
I would like to have the value of the property assigned during AfterPublish() show up in the UI when the publish is complete.
An alternative would be to somehow force the reload of the editor page (but we are diving way too far into customization here, IMHO).
What ends up happening is that when the user publishes the item again from that same page (without clicking the item in the tree to reload the page, etc...imagine they made a typo or forgot something) the AfterSave() event handler has no value in the property and it generats a new guid/unique and publishes again to the external source... now I have two of the same item in the external destination. This will happen for as many times as someone clicks publish without reloading the page. The result is that there are as many items in my external destination as there have been publishes without reloading the editor ui.
Can anyone recommend a fix or where I might look to get this working as expected?
It's almost like the umbraco editor is doing everything client side (via Ajax or something) and not reloading the editor page at all. This was working as expected in 4.9.x if I remember correctly.
This is also happening with Media.AfterSave()...
Things I have tried: umbraco.library.UpdateDocumentCache(<docId>) in the AfterSave, calling Save() on the document, setting the id in the BeforeSave() event (using umbraco.library.UpdateDocumentCache(<docId>) there actually fails)
Thanks in advance.
Hi Brice, Any resolution on this issue? I am experiencing the same thing and have not solved the issue of having a GUID/key being generated and having the UI updated after the publish event.
Steps to reproduce:
Regards,
Chris
Hi Brice, Here is a simple solution that solved my problem:
On completion of your Afterpublish Handler the following code will reload the iframe that holds your node properties:
Keep in mind that you should not abort the thread until the end of your operation in Umbraco. Here is a good post of pitfalls to avoid when calling a the redirect.
http://briancaos.wordpress.com/2010/11/30/response-redirect-throws-an-thread-was-being-aborted/
Chris,
Good find and thanks for the follow up. Our workaround was to just assign defaults on Document.New and they would be there in the editor for the save.
Brice
is working on a reply...