How to add a check and error handling in the "version" method when pushing the button "Create New Version"

Dear all,

Is it possible to add validation checking and error handling when I press the “Create New Version” button from the author dashboard? I was able to create a new plugin and hook the ‘version’ method to check it, but since the ‘version’ method originally doesn’t have error handling built in, an error message is displayed on the screen. not.

I’m parsing the following class module, but it’s difficult for me to add error handling to the “version” method. So, please help me.

I am using with OPS
I’m sorry if it has already been resolved. If so, please let me know the solution.

Thanks in advance,

Hi @Minoru_Tanabe,

As you found, you can use the Publication::version hook to perform some action when a new version is created. But the API and UI have no concept of an “invalid” version. A new version can always be created.

Can you explain a little bit more what you want to accomplish? There may be an alternate way to do this.

For example, the Publication::validatePublish can be used to prevent a version from being published. Perhaps adding the validation step there would make more sense?

Hi @NateWr Thank you for your messsage.

I investigated this matter further and found it to be a very difficult customization.
It’s very complicated to explain, but what I want to do is let the author fill in the required fields when the author presses the CreateNewVersion button.

However, error handling at this stage turned out to be difficult.
Specifically, the error passing after the validation check does not go well.
I think the point is how to use “$ errors”. In “validatePublication”, “$ errors = & $ args [0];” is written at the beginning, but in “versionPublication”, it cannot be written at the beginning, so the rear part. If you write in ($ errors = $ args [3];), you cannot pass the error.

  public function validatePublication($hookName, $args) {
    $errors =& $args[0];
    $action = $args[1];
    $props = $args[2];
    $allowedLocales = $args[3];
    $primaryLocale = $args[4];

  public function versionPublication($hookName, $args) {
    $newPublication = $args[0];
    $oldPublication = $args[1];
    $request = $args[2];
    $errors = $args[3];

Therefore, I decided to leave it to the next stage (when the Save button is pressed), but since there are multiple entry screens such as metadata, contributors, galleys, and references, validation with the Save button is incomplete.

So, I would like to give up on these validations and just display a warning message in the dialog when the CreateNewVersion button is pressed.


Hi @Minoru_Tanabe,

Publications have two different validation steps that are applied: validation when any publication data is saved (Publication::validate), and validation before a publication is published (Publication::validatePublish). I think the best validation step for you to use is Publication::validatePublish. If you try to apply validation earlier, the author will be required to enter a complete set of valid data all at once. This presents usability problems when there is a lot of data to enter.

If I understand you correctly, you want to transform the “Create New Version” button into a wizard-like workflow that leads the user through a series of steps from creating a new version to publishing that new version. Is that right? If so, it might be best to simply replace the button with a link to your own page where you can add a step-by-step wizard.

Hi @NateWr ,

Yes, the fatal problem with the CreateNewVersion button is the multiple flat input screen configurations. Since there is a Save button on each screen, a comprehensive validation check cannot be performed. Moreover, the moderator does not notice when the author pressed the Save button (“Title’s metadata has been modified.” is set to " Enable" in the moderator’s Notification settings, but for some reason the email is skipped to the moderator. I don’t know.).

As you pointed out, changing to a wizard-like workflow similar to when submitting a new one would work, but it’s beyond the scope of customization and won’t be easy.
I look forward to the OPS version in the near future.


a comprehensive validation check cannot be performed

I suspect this may just be a misunderstanding of how validation is handled in the system. If you can identify what validations you want to apply and what notifications you want to be sent – and for what purpose – there may be a way forward. Can you describe your customization in user stories? eg -

As an author
I want to xxxxx
so that I can xxxxx

As a moderator
I want to xxxxx
so that I can xxxxx

Hi @NateWr,

Thank you for your reply.

The cutover deadline for the preprint system currently under development is approaching, so I would like to postpone the customization.
So, I request the following for the future.

As an author, I would like to do the following.

  1. After pressing the CreateNewVersion button, press the revision completion button after modifying the items on each form.
  2. At that time, validate the required items.
  3. After clearing all validation checks, the revision is completed and it is automatically notified of the completion of the revision to assigned moderator.

As a moderator, I would like to do the following.

  1. Receive a notification from the author that the revision has been completed.
  2. And then, the moderator check the contents and publish if there is no problem.

That’s all.
Thank you very much.

Thanks @Minoru_Tanabe! That’s a great description. I’ve copied it over into a post in our Feature Request forum: Add a step-by-step workflow to OPS when authors create a new version

@NateWr , Thank you for your post in your Feature Request forum!
I hope that this feature will be implemented into OPS in the near future.

This topic was automatically closed after 13 days. New replies are no longer allowed.