对于某些参数,有人不希望允许使用任意字符串,而是希望将输入限制为少量备选选项之一。这些参数应该指定为 ChooseOne 类型,包含参数的对象必须具有另外两个成员:
|
使用 ChooseOne 参数类型,我们可以强化前面的示例,将业务部门限制为少量预定义的值之一:
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 + '"'); } };
当执行此工作流时,unit 参数不能手动输入-它将从指定的可用选项列表中进行选择。