Invoking Workflow Rules

Calling workflow rule services from AXVW forms

If the service method does not require input parameters, and does not return any data, application views can call it using a standard view command.The command must specify the workflow rule's application ID and rule ID, for example:

<action>
<title>Approve Request</title>
<command type="workflowRule" ruleId=" AbHelpDesk-helpDeskApprove "/>
</action)


If the workflow rule is defined using class-level security, then the command must specify the workflow rule's application ID and rule ID, and the service method name, for example:

<action>
<title>Update Area Totals</title>
<command type="workflowRule" ruleId=" AbCommonResources-SpaceService-updateAreaTotals "/>
</action)


You can also use view commands to call service methods that take parameters that are compatible with standard view commands:

  • If the command action is owned by the form or console panel, the command sends the form record values.
  • If the command action is owned by the grid row (field), the command sends a record containing primary keys of this grid row.
  • If the command action is owned by the grid panel , and multiple selection is enabled, the command sends an array of records containing primary keys of selected grid rows.

Calling workflow rule services from Java Script

As discussed in the System Integration section of the documentation; you can also call services and test their return values from the Java Script Workflow object. This lets you pass arbitrary parameters to services, and also to handle service response values.

try {
var parameters = {
name: value,
name: value
};
result = Workflow.call(" AbHelpDesk-helpDeskApprove ", parameters);
... code that uses the result goes here ...
} catch (e) {
// handle error: display an error message etc.
Workflow.handleError(e);
}


If the workflow rule is defined using class-level security, then the Java Script code must use the Workflow.callMethod() instead of the Workflow.call() :

try {
var costId = ...;
var dateStart = ...;
result = Workflow.call(" AbCommonResources-CostService-createScheduledCosts ", costId, dateEnd);
... code that uses the result goes here ...
} catch (e) {
// handle error: display an error message etc.
Workflow.handleError(e);
}

Calling service methods from other service methods

Service methods can be called from other service classes. All services are exposed to the application Java code through the standard Context object.

public void myService() {
...
// get the service instance
LeaseAlertHandlers handlers = (LeaseAlertHandlers) ContextStore.get().getEventHandler('LeaseAlerts');

// call one of the business methods
generateAlerts();
...
}