How to refresh backoffice view after setting value during ContentService_Saving event handler?
In a custom made ApplicationEventHandler class I have a ContentService_Saving event handler that changes some values during the page saving process based some admin rules.
The code looks like this:
private void ContentService_Saving(IContentService sender, SaveEventArgs<Umbraco.Core.Models.IContent> e)
{
foreach (var entity in e.SavedEntities)
{
...
entity.SetValue("editCaseVisibility", true);
entity.SetValue("testTextbox", "tralalala");
...
dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(nestedFields);
...
// changing some of the json's property values
...
// serializing the updated json object
string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(json);
// updating the Nested Content property in the page
entity.SetValue("nestedFields", serialized);
}
}
The properties "editCaseVisibility" (checkbox) and "testTextbox" (textbox) both get refreshed in the view and show the values I've set in the event handler. However, the Nested Content field "nestedFields" does not show the newly set values. I actually have to manually refresh the whole webpage in the browser to see the new values. Why is that? And is there a solution for it?
How to refresh backoffice view after setting value during ContentService_Saving event handler?
In a custom made ApplicationEventHandler class I have a ContentService_Saving event handler that changes some values during the page saving process based some admin rules.
The code looks like this:
The properties "editCaseVisibility" (checkbox) and "testTextbox" (textbox) both get refreshed in the view and show the values I've set in the event handler. However, the Nested Content field "nestedFields" does not show the newly set values. I actually have to manually refresh the whole webpage in the browser to see the new values. Why is that? And is there a solution for it?
hi,
I found this solutions
https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/92658-force-refresh-backend-page-after-save-publish#comment-293034
https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/Utilities/WebApiHandler.cs#L24
is working on a reply...