Possibility to override content's Modified datetime

Hey guys,

I need to be able to override the modified date of an article. I followed the documentation and was able to set the published.from using the contentlib modify method.

I was able to modify the created date easily, with GitHub - runarmyklebust/createdFix but that don’t allow me to update the modified date.

Is this possible?

Thanks!

Since XP 6.9.x, you can use the Node library to do this.

  1. Include lib-node in your build.gradle
  2. Require /lib/xp/node in your JavaScript controller
  3. Use the connect() method inside the Node lib to connect to the content repo (with ID ‘cms-repo’)
  4. With the RepoConnection object that is then created, use its modify() method to set a new value for modifiedTime. You do this using an editor function, as per the example in the Enonic XP JavaScript Library reference documentation
  5. You can then use the push() method from the same RepoConnection to push your changes to the Master branch if desired
1 Like

NB! Be very careful when changing content data through the repo API, as this bypasses all validation rules for the data (like going directly to SQL to manipulate data created by an application). However, the suggestion from @bhj should work fine. An alternative is to export the data, modify the export and import the data again.