Metastorm BPM, out of the box does allow you to specify whether a form field is mandatory so that when you deploy your procedure and the user is interacting with your forms, they are forced to fill in these mandatory fields. This is great if your forms are basic and you don’t mind having a thin red line appear around the field (great if you’re form theme is red, but ugly otherwise), but they don’t always do the trick.
Let’s take the example of a form that contains a grid that is non editable. You add fields to the form that the user fills in, then they click an ‘Add Line’ button and you insert the field values into the underlying table, the grid refreshes and the fields are all cleared ready for the next line. This works well as it allows you ensure only the correct data is being added to the table/grid by checking field value logic in the buttons ‘when pressed’ event. The problem arises however if you mark any of these fields mandatory. As you add data to the grid, you clear the lines and so at the point of form submission, these fields WILL be empty and so if a mandatory field is enforced, you won’t be able to submit the form.
I tend to avoid using the Metastorm native mandatory field feature and implement my own client side validation using JScript. You can customize your alerts() and can employ more intelligent field validation logic. Recently I’ve been playing with mandatory logic and field styles so that when the client side script decides that a value is missing for a mandatory field, it not only alerts you via a pop up, but changes the fields background colour and text colour to bring the omission to their attention. This is useful because for those users who think they can storm through your forms, it makes their missed values pretty obvious and in addition when they do in fact correct their missing values and attempt a resubmit, the script will return the field styles back to normal.
I should mention that the script does rely on your fields names conforming to the Metastorm recommendation of a three character data type prefix, e.g. txtMyField or curMyCurrency, so if this isn’t the case in your procedures, you may need to tweak the script.
Once the JScript is copied into your procedure (or library), go to the form you wish to implement mandatory field validation to and in the forms ‘client extensions’ area, type:
(replacing the fields names with the fields you wish to have mandatory values). The script will take care of the rest.