Copied to clipboard

Flag this post as spam?

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


  • Robert 33 posts 173 karma points
    Nov 15, 2018 @ 12:22
    Robert
    0

    Programmatic access to property history

    Is there a way using any of the umbraco backoffice API's whereby one can read a history of the values of a certain property? E.g. imagine a password field for a certain document type, can I read in c# a history of the different values that this property has been set to? The data seems to be in the cmsPropertyData table but would prefer to access via an offical api.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Nov 15, 2018 @ 13:15
    Dan Diplo
    0

    You should be able to use the Content Service to do this. You can call the GetVersions(id) method it has that exposes all the previous content versions. You can then select your property data from each previous version.

    ApplicationContext.Services.ContentService.GetVersions(1234);
    
  • Robert 33 posts 173 karma points
    Nov 16, 2018 @ 15:15
    Robert
    100

    Thanks - this is what I was looking for and it seems to work well.

    Occasionally however I notice that this method returns null for some of the property values, but then it's OK again. Seems to be random.

  • Robert 33 posts 173 karma points
    Nov 19, 2018 @ 10:17
    Robert
    0

    Looking at the umbraco source code for ContentService.GetVersions(int id) I notice that it ends up using a cache in the repository layer: It passes true to the ProcessQuery method: withCache = true

    return ProcessQuery(sqlFull, new PagingSqlQuery(sqlIds), true, includeAllVersions:true);

    Is there are way that we can avoid using the withCache option? In other words I want to be able to call the ContentService.GetVersions(int id) knowing that it will go straight to the database each time.

Please Sign in or register to post replies

Write your reply to:

Draft