Copied to clipboard

Flag this post as spam?

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


  • Peter Bridger 11 posts 52 karma points
    Mar 29, 2012 @ 15:16
    Peter Bridger
    0

    Using Document.BeforePublish to update a property

    I'm registering against the Document.BeforePublish Umbraco event handler, so that my application can strip out spatial data (Which is held in Umbraco serialized to XML).

    When new spatial data is detected it's added to a seperate table in the database which is designed to hold spatial data in a format it can be searched/manipulated using the SQL Server 2008 spatial tools.

    The long and short of this is that when an Umbraco document containing spatial data is published, the spatial data is inserted into another table and then the id of the newly inserted spatial data is added back into the Umbraco document.

    sender.getProperty(umbracoPropertyAlias).Value = JsonConvert.SerializeObject(documentGeometry);

    This works - I can see from looking at umbraco.config that the spatial object in Umbraco has been updated with the id - good news! :)

    The bad news is that in the actual Umbraco editor which I've got open in my web browser which reloads after publishing doesn't reflect the updated spatial property in the document which I've just updated in the event handler.

    Is this an issue with Umbraco just using what's in the viewstate, rather than reloading data from the document object? Either way, what's the best known solution to this problem?

    Thanks
    Pete


  • Robert J. Bullock 386 posts 405 karma points
    Feb 13, 2013 @ 16:32
    Robert J. Bullock
    0

    This is a bit of an old post, but I just noticed the same behavior. Did you ever figure out the issue?

  • Peter Bridger 11 posts 52 karma points
    Feb 21, 2013 @ 15:18
    Peter Bridger
    0

    Unfortunately not.

    The project which used this particular piece of code is currently on hold, meaning I've not yet needed to find a fix.

    If you're able to find a solution, I'd really appreciate it if you could share your solution.

    Good luck!

  • Robert J. Bullock 386 posts 405 karma points
    Feb 21, 2013 @ 15:29
    Robert J. Bullock
    1

    Peter, actually I found a solution... You need to call this after your document save:

    BasePage.Current.ClientTools.ClearClientTreeCache();

    At least that worked for me with Umbraco 4.11.4

Please Sign in or register to post replies

Write your reply to:

Draft