Using Javascript In The Approval Workflow - X-Rite Pantone Virtual Light Booth User Manual

Table of Contents

Advertisement

3. Using JavaScript in the Approval Workflow

Using JavaScript you can customize the approval workflow in a very flexible way. It can be
mapped to individual workflows (e.g. a multi-step approval process).
The general outline of the JavaScript process is as follows:
Item {
function validateInputs(lApprovalFields) {
...
return result;
}
function evaluateApproval(lApprovalFields) {
...
return [state, message, color];
}
}
You need to declare an item with two methods, validateInputs and evaluateApproval. Both
receive a list of the metadata fields as defined in the definition XML files, including their current
values. The ID of the field with index i can be accessed using lApprovalFields[i].strFieldID and
the value using lApprovalFields[i].value. The field ID corresponds to the value of the ID attribute
specified for the respective property in the definition XML.
The validateInputs needs to return true or false depending on whether the inputs of the user are
viable at all. With this method you can model dependencies between different fields (e.g. if a
certain box is checked, another comment field has to be filled by the user). If you return false
here, the VLB software will not let the user save the entered data.
The evaluateApproval needs to return a 3-tuple of values. State should be an integer and can
have three different values:
0: not evaluated, evaluation not possible (e.g. the user has not entered sufficient data)
1: approved
-1: rejected
2: custom state
In case the state is 2 / custom, the other two members of the tuple come into play: message and
color. The VLB will then display the given message with the given text color in the left panel of
the approval UI. In case of the other states, the VLB software will disregard this information and
display its default messages.
Before adding your own JavaScript to the XML, please ensure that you encode it correct. The
best way to ensure this is to use a dedicated XML software editor.
In the ExampleApprovalMetaDataDefinitions.xml an example script is supplied that shows all
the features discussed above:
The Approval status switches automatically from Rejected to Approved if certain thresholds
-
are passed
A special workflow is implemented if the quality is generally good but artifacts exist
-
V i r t u a l L i g h t B o o t h
31

Advertisement

Table of Contents
loading

Table of Contents