Constrained Workflow Parameters
For some parameters, you might not want to allow an arbitrary string, but would rather limit input to one of a small number of alternatives. These parameters should be specified to be of type ChooseOne, and the object containing the parameter must have two additional members:
Table 9-4 Constrained Parameters Required Members
| Required Member | Type | Description |
|---|---|---|
|
|
Array |
An array of strings that specifies the valid options |
|
|
Array |
An array of strings that specifies the labels associated with the options specified in |
Example 9-4 Using the Workflow ChooseOne Parameter
Using the ChooseOne parameter type, we can enhance the previous example to limit the business unit to be one of a small number of predefined values:
var workflow = {
name: 'Create share',
description: 'Creates a new share in a business unit',
parameters: {
name: {
label: 'Name of new share',
type: 'String'
},
unit: {
label: 'Business unit',
type: 'ChooseOne',
options: [ 'development', 'finance', 'qa', 'sales' ],
optionlabels: [ 'Development', 'Finance',
'Quality Assurance', 'Sales/Administrative' ],
}
},
execute: function (params) {
run('shares select ' + params.unit);
run('filesystem ' + params.name);
run('commit');
return ('Created new share "' + params.name + '"');
}
};
When this workflow is executed, the unit parameter will not be entered manually; it will be selected from the specified list of possible options.