Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.
Endpoint Management Community Blog

Handling Dates with Custom Validation in Workflow

Created: 11 Sep 2008 • Updated: 11 Sep 2008
LNew's picture
0 0 Votes
Login to vote

I ran into this problem when creating a workflow for a standard time off type of request - there wasn't a way to force the 2nd date (in this case, the end date) to key off of the 1st, or start, date and therefore prevent the user from selecting something like 9/27/08 to 9/25/08 for his/her time off.

A coworker of mine helped me come up with a way of comparing the dates inside of the form itself, rather than looping out of the form. This way, the workflow would not progress if the end date was not greater than the start date and we can utilize custom validation to handle both the model and the error message. Consequently, the user would be required to fix the date issue right then and there.

There may be an easier/quicker way to handle this, but here's what we came up with:

In this example scenario, we will use what may be a typical structure of a user-submitted request form and a manager approval form (the latter being utilized solely for the sake of the information transmitting somewhere).

In the submission/request form, we will use a couple of labels and two date picker components, one for the "start date" and one for the "end date". The form utilizes a Submit button as its output.

We must have at least one component in the form set to Optional, so we will use the "end date" date picker component. It will be this component that will hold the custom validation.

  1. Double-click the "end date" date picker and on the Functionality tab of the Edit Component window, scroll down to the Validation section.
  2. Check Use Custom Validation and click the ellipse next to Custom Validation Model.
  3. In the embedded decision model that opens, add a Date Greater Than component.
  4. Add another End component and hook up your true and false links respectively.
  5. Name your true path End component something like "valid" and your false path "not valid".
  6. Double-click your Date Greater Than component and on the Evaluation tab, select your "end date" (EndDate in this example) for the First Date Variable Name.
  7. Select your "start date" (Start Date in this example) for the Second Date.
  8. Click OK then double-click your "valid" End component.
  9. On the Configuration tab, click the ellipse next to Mapping, and select Null Value.
  10. Click OK twice to get out of the component editor and then double-click the "not valid" End component.
  11. Click the ellipse next to Mapping, and select Create Value.
  12. Type a description for your validation - I typically use the error message as my description, so for this example, we will utilize "The end date must be greater than the start date." Type the same message into the Name field. Leave the Level as Warning.
  13. Click OK until you get out of the form and then out of the interaction model.
  14. Run your process in the debugger. If you set everything up correctly, you should receive a nice little javascript error if your selected end date is not greater than the start date.