cancel
Showing results for 
Search instead for 
Did you mean: 

Share Workflow Form Constraints

stevegreenbaum
Champ in-the-making
Champ in-the-making
I am looking for a way to perform additional validation on form data when a transition button is clicked. Example, in a screen where there are two possible transitions: approve, reject, if Approve transition selected, then approve amount must not be zero. If reject is selected, then amount must equal zero. I don't want to put this logic in the transition since then I can't display the message on the current screen. Would the post processing filter allow me to validate the amount and not let them leave the screen if incorrect?

I've also looked at the constraint handler, but I don't know if I can put an event handler the click of a transition button. 

Can a constraint previously defined in the model be used from a constraint handler?  If so, how do you reference the constraint?  

Thanks
3 REPLIES 3

gavinc
Champ in-the-making
Champ in-the-making
It sounds like the best way to solve this would be to add a callback to the forms runtime so you get informed when the form is being submitted. If false is returned from the callback the form does not get submitted so you could perform your custom validation in here.

The tricky bit is getting hold of the forms runtime instance to register the callback. However, this post may well help you: http://forums.alfresco.com/en/viewtopic.php?f=47&t=36027#p105602

stevegreenbaum
Champ in-the-making
Champ in-the-making
Ok, thanks I'll take a look at that technique.

I believe that this use-case is fairly common, perhaps support for a validation handler that is triggered on a transition would be a good enhancement.

Here is a jira enhancement request.  Please vote for this enhancement:  https://issues.alfresco.com/jira/browse/ALF-6052

gavinc
Champ in-the-making
Champ in-the-making
Yes, I agree.

It's essentially allowing people to easily plugin submit time/form level validation handlers which there already is an enhancement raised for: http://issues.alfresco.com/jira/browse/FORM-15 feel free to raise a more publicly visible JIRA issue though.