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.

 

Initialize code can be used to set initial field values, and conditionally set the initial step for the document.  It can also be used to send notifications to role users.
 
Advance code is executed whenever the user presses the Next button in the browser interface, normally to change the current step of the document.  This code can set errmsg$ to prevent the advance from changing the step.  If the code sets a new step value, that step is honored.  Otherwise the step is automatically set to the next step.  This code can also send notifications to roles.
 
Finalize code is executed when the document's current step is the last step, and the user presses the Finish button.  After running the Advance code without errmsg$ set, and without a different step being set by that code, the flow history, field data, and added attachments are updated in the source library document, and this code is run.

 

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.

 

 

 

df_flowdef_scripting

 

 

 

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