Metastorm 7 : Mandatory Fields

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.

Click here to download the client-side JScript

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:

OnSubmit=form_checkMandatory (“txtNameField”,”intAgeField”)&Language=JScript

(replacing the fields names with the fields you wish to have mandatory values).  The script will take care of the rest.


Metastorm BPM : Copy current folder ID to the clipboard

When I’m troubleshooting folder issues by running tests with forms via the Metastorm web client, sometimes I quickly need to know the folderID of the folder I’m currently working on in order to query the database for further information about the folder (such as variable values etc).  Generally, unless you’ve already done what’s being discussed here, you won’t have the folder ID available to you from the web client, only the folder name shows in your folder list and in order to find out the folder ID, you  then use the folder name to query the eFolder table.  I want to go from looking at the folder to querying the database as quick as possible.

There are different ways to program your forms to show you the folderID of the current folder via the web client, one such method could be a calculated field showing the %FolderID value, but let’s face it, you don’t want your users seeing this do you?  One alternative method would be to have a button, visible only to Metastorm Admins for example (query the eAssignment table for the current users roles) which then queries the database for the current folder name.  Again, not bad, but that’s two queries more than we need.

When your Metastorm form loads in the browser, it’s pure HTML and Javascript.  If you take a look at the HTML source of the form, you’ll notice that there are a collection of hidden input fields loaded and one of those holds the value of the current folders ID.  This being the case, we can just grab the value of this hidden field. My solution is to use the form onLoad event for each of my forms to run a simple javascript function which copies the current folder ID to the clipboard for me.  This way, whenever I’m trouble shooting any folder issues, I instantly have the applicable folder ID copied in memory and ready for me use in my SQL queries.  I just wish SQL Server Management Studio would render the SQL query I am currently thinking about to save me even more time.

Here’s the code:

I should mention that this works with IE only and so if you are using the later SR releases of Metastorm 7.6 and support firefox in your setup, this won’t work.