ワークフローは、audit 関数を呼び出すことによって監査レコードを発行できます。audit 関数の唯一の引数は、監査ログに記録される文字列です。
実行にある程度の時間が必要な複雑なワークフローの場合は、そのワークフローを実行しているユーザーに明確な進捗状況を表示すると有益です。ワークフローの実行をこの方法で報告できるようにするには、execute メンバーが手順の配列を返すべきです。各配列要素には、次のメンバーが必要です。
|
全体としてのワークフロー上の execute 関数と同様に、各段階の execute メンバーは、そのワークフローへのパラメータを含むオブジェクトを引数として受け取ります。
使用例 4-7 ワークフローの実行のレポート例として、3 つの手順で新しいプロジェクト、シェア、および監査レコードを作成するワークフローを次に示します。
var steps = [ { step: 'Checking for associated project', execute: function (params) { try { run('shares select ' + params.unit); } catch (err) { if (err.code != EAKSH_ENTITY_BADSELECT) throw (err); /* * We haven't yet created a project that corresponds to * this business unit; create it now. */ run('shares project ' + params.unit); set('mountpoint', '/export/' + params.unit); run('commit'); run('shares select ' + params.unit); } } }, { step: 'Creating share', execute: function (params) { run('filesystem ' + params.name); run('commit'); } }, { step: 'Creating audit record', execute: function (params) { audit('created "' + params.name + '" in "' + params.unit); } } ]; 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' ], } }, validate: function (params) { try { run('shares select ' + params.unit); run('select ' + params.name); } catch (err) { if (err.code == EAKSH_ENTITY_BADSELECT) return; } return ({ name: 'share already exists' }); }, execute: function (params) { return (steps); } };