Scripting |
Top Previous Next |
Scripting enables customized actions to be performed as documents enter, move through, and leave the flow. There are three sections: initialize, advance, and finalize. Each of these is pre-populated with parameter and field definitions, and each provides a custom section where additional code can be entered.
In the custom code sections, you can enter any valid UnForm scripting code, which is based on the PxPlus Basic language. The code is identical to that used to program code blocks, except that block if statements are not restricted from using curly braces (see Block If, below).
Scripting makes heavy use of objects, as several are exposed automatically while the script runs, used by the auto-generated code and available for custom code, the most important of which is "doc", a docflowdoc object representing the current document in the flow, but also docflow, filter, lookups, validation, and notify object variables ("filters" is an alias for "filter", "validations" is an alias for "validation"). Also, in the finalize routine, a subdoc property template is provided, as returned by the library object's getsubdoc() method, for the newly created XML document generated automatically when the document is updated back into the source archive library. You can use this template to access the XML file, or to obtain document- or sub-id values for further processing with a library object.
Block If
This is valid in custom scripting:
if a=b then { # code if a=b } else { # code if a<>b }
This is valid in both custom scripting and code blocks:
if a=b then # code if a=b else # code if a<>b end if
|