JavaScript API Reference/Ab.workflow.Workflow object

runRule(workflowRuleId, parameters, callBackFunction, callbackObject, timeout)

Call specified workflow rule, wait until the execution is finished and pass its results to specified callback function. The workflow rule is executed in synchronous mode, i.e. the runRule() function does not return to the caller until after the workflow rule execution is finished and the result is received.

Parameters:

  • workflowRuleId (String): workflow rule ID
  • parameters (JS object): input parameters to be sent to the workflow rule; this object can contain:
    •  simple properties, such as strings or numbers
    •  other objects or arrays (that can contain other objects or arrays), encoded in JSON notation
  • callbackFunction (function): callback function reference (not name)
  • callbackObject (reference): (optional) JavaScript object that contains the callback function; not required for global callback functions
  • timeout (integer): (optional) timeout in seconds

Examples

Call a workflow rule without parameters using a global callback function:

function getUser() {
Workflow.runRule('AbCommonResources-getUser', {}, afterGetUser);
}

function afterGetUser(result) {
...
}


Call a workflow rule without parameters from the object, use an object callback function:

Ab.example.UserInfo = Base.extend({
getUser: function() {
Workflow.runRule('AbCommonResource-getUser', {}, this.afterGetUser, this);
},

afterGetUser: function(result) {
...
}
}


Call a workflow rule, passing a parameters object and using a callback function:

var reportOptions = {
'orientation': 'landscape',
'header': 'standard',
'footer': 'none'
};
var reportYears = [005, 2006, 2007];
var parameters = {
'reportName': 'ab-project-report-by-year.axvw',
'reportOptions': toJSON(reportOptions),
'reportYears': toJSON(reportYears)
};
Workflow.runRule('AbReports-generateReport', parameters, afterGenerateReport);