Update item without changing ModifiedAt

Thread is closed for posting
3 posts, 1 answers
  1. Viktor
    Viktor avatar
    14 posts
    Member since:
    Dec 2011

    Posted 25 Sep 2017 Link to this post

    Hi guys,

    Is there a way to modify an Item, but ModifiedAt to stay the same?

    The case is that I want to show my items sorted by last edit, which would naturally be done by sorting by ModifiedAt. The problems comes from the fact that I also have ViewCounter property, which is incremented in the Cloud code in afterRead() hook. This would update ModifiedAt and would mess-up the sorting.


    Is there a way to achieve this?




  2. Answer
    Anton Dobrev
    Anton Dobrev avatar
    609 posts

    Posted 27 Sep 2017 Link to this post

    Hello Victor,

    The system field ModifiedAt (as the other system fields) is designed to be automatically managed and its value set to the respective date and time of the latest update. It is not possible to bypass this behavior. 

    One of the available approaches you may consider is using the X-Everlive-Override-System-Fields header with a master key authentication and supply you own value for the system fields. 

    data.withHeaders({'X-Everlive-Override-System-Fields': true}).update....

    Another approach may be to make the sorting on another, custom field, for example, LastEditedAt which will will allow to manage and set the value of this field as per your business requirements. 

    Let me know if this helps and if I may be of further assistance. 

    Anton Dobrev
    Progress Telerik
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
  3. Viktor
    Viktor avatar
    14 posts
    Member since:
    Dec 2011

    Posted 27 Sep 2017 in reply to Anton Dobrev Link to this post

    Hi Anton,

    Thank you for the answer. I was leaning towards similar approach.



Back to Top