0

Thanks to a resolution of another problem, we wish to call self.on('books:beforeSave', ...) for all pieces.

We are using apostrophe-workflow. Since they have not changed, using "Batch Commit" from the CMS does not trigger anything.

Is there a way to force commits even if no changed occurred? We'd like to avoid opening a hundred pieces, modify them, cancel the modification, and then commit :)

jansensan
  • 633
  • 1
  • 8
  • 23
  • Here is additional information that could help the investigation: the `req` parameter does not provide a `piece` property when saving from the CMS using the checkboxes and then choosing "Batch Commit". Does apostrophe-workflow not provide this property if there were no changes? – jansensan Nov 18 '20 at 22:34
  • Update on the previous comment: I was trying to extract piece from req (`const {piece} = req`) whereas I did not notice how `piece` was the second parameter of the method. However, the batch commit issue remains. At this point I dont see any resolution, I'll just go through all pieces manually to commit them on at a time, since that works. – jansensan Nov 19 '20 at 15:32
  • The `batch-commit` route will commit all of the specified items, whether the draft actually is newer than the live version or not. I think your problem must lay elsewhere. – Tom Boutell Nov 22 '20 at 23:25
  • @TomBoutell so it would seem, or maybe I am not polling the property properly? In the template, I am using `{%- if piece.citations -%}` to render (or not) the citations macro. It turns out that in edit mode, this prop does not exist, but in anonymous mode, it does. – jansensan Nov 25 '20 at 19:56
  • What is piece.citations? What type? – Tom Boutell Nov 27 '20 at 02:17
  • @TomBoutell It is an object, created on before save, see https://github.com/jansensan/arts-et-medias/blob/master/lib/modules/aem-books/index.js#L302. This needs to be done this way, as it depends on user input, but cannot be left for users to do. This property is added then, and shows properly in the db. This was a results of https://stackoverflow.com/questions/64850545/how-to-add-update-piece-field-when-the-user-saves-commits – jansensan Dec 03 '20 at 21:38

0 Answers0