Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    May 18, 2012 @ 05:44
    Nathan Woulfe
    0

    Update node from _AfterSave

    Righto, I'm getting a headche. I'm using Document_AfterSave to check a property value. If the value meets a certain criteria it is changed, the document re-saved and a warning message displayed. All good, works nicely.

    What doesn't work is the property displayed in the back office remains as the previous value until the node is reloaded. I understand why, but would like to update the displayed value to the new value when it is updated in _AfterSave, just like it would be on a regular save event.

    I've tried to work from examples using parent.refreshNode, with no success.

    Is this possible? Code snippet below - any suggestions would be awesome. I'm on 4.7.1.

    void Document_AfterSave(Document sender, umbraco.cms.businesslogic.SaveEventArgs e)
            {
                DateTime dt= Convert.ToDateTime(sender.getProperty("date").Value.ToString());
                TimeSpan ts = date- DateTime.Now;
                if (ts.Days > 180)
                {                
                    Page page = HttpContext.Current.Handler as Page;
                    sender.getProperty("date").Value = DateTime.Now.AddDays(90);
                    sender.Save();
                    page.ClientScript.RegisterClientScriptBlock(this.GetType(), "s", "alert();", true); ///Need some magic here to refresh the node... ///
                }
            } 
  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 18, 2012 @ 16:19
    Jeroen Breuer
    0

    This topic might help, but it doesn't have a solution: http://our.umbraco.org/forum/developers/extending-umbraco/31225-Updating-property-value-on-Save

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft