Some thoughts on validations for SAP Interactive Forms
I often get asked where validations for Interactive Forms should be implemented. There is the option to do it locally in the form using the possibilities provided by the Interactive Form (e.g. patterns or scripting) or it can be done on the back-end after the data is submitted back from the form. When you have to decide where to implement your validations you should also take a look at your scenario. If it’s an offline scenario you cannot do a server roundtrip for validations. Hence, validations have to be implemented twice: In the form and on the back-end. The recommendation here is to implement only validations that ensure data accuracy. More complex validations like verifying business partners should reside in the back-end. In other words do not put too much business logic into the form itself and error handling takes place on the back-end.
For offline scenarios a PDF has to contain everything you need for validations meaning the additional data (e.g. lists of allowed values) used for validating input is part of the PDF form and thus increasing it’s size. For online scenarios it’s easier since you can do a server roundtrip so you do not have to implement validations twice and include additional data. You only want to implement it on the back-end.
For defining validation patterns it is necessary to know the pattern language. I strongly recommend taking a look at the Picture Clause Specification that is contained in Part 3 of the XFA specification. By the way if you have not seen my blog about “Useful documentation for developing Interactive Forms” I recommend looking at it 😉
In the picture clause specification you can find a pretty good description of patterns. Patterns are used in various ways for fields. You can define a display pattern, an edit pattern, a validation and a data pattern. A display pattern is used to format a data value when it is displayed on the screen. The edit pattern is used when a data value is edited. Validation patterns are used if a data value has to be validated after entry. And with the data pattern you can define in which format a data value is stored in the XML data.
You should add validations to your form wherever possible. Especially for offline scenarios additional “intelligence” greatly improves usability and acceptance. One thing that always should be done is to re-validate on the back-end to make sure no one manipulated the data.