This is a migrated thread and some comments may be shown as answers.

Update item without changing ModifiedAt

2 Answers 32 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Viktor
Top achievements
Rank 1
Viktor asked on 25 Sep 2017, 11:45 AM

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?

 

Thanks,

Viktor

2 Answers, 1 is accepted

Sort by
0
Accepted
Anton Dobrev
Telerik team
answered on 27 Sep 2017, 08:31 AM
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. 

Regards,
Anton Dobrev
Progress Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Viktor
Top achievements
Rank 1
answered on 27 Sep 2017, 08:35 AM

Hi Anton,

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

 

Thanks,

Tags
General Discussion
Asked by
Viktor
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Viktor
Top achievements
Rank 1
Share this question
or