Workflows that do not operate on input have limited scope; many workflows need to be parameterized to be useful. This is done by adding a parameters member to the global workflow object. The parameters member is in turn an object that is expected to have a member for each parameter. Each parameters member must have the following members:
|
The type member must be set to one of these types:
|
Based on the specified types, an appropriate input form will be generated upon execution of the workflow. For example, here is a workflow that has two parameters, the name of a business unit (to be used as a project) and the name of a share (to be used as the share name):
var workflow = { name: 'New share', description: 'Creates a new share in a business unit', parameters: { name: { label: 'Name of new share', type: 'String' }, unit: { label: 'Business unit', type: 'String' } }, execute: function (params) { run('shares select ' + params.unit); run('filesystem ' + params.name); run('commit'); return ('Created new share "' + params.name + '"'); } };
If you upload this workflow and execute it, you will be prompted with a dialog box to fill in the name of the share and the business unit. When the share has been created, a message will be generated indicating as much.