Starting Long-Running Jobs

Calling jobs from forms

Application views can start a job using a standard view command.The command must specify the jobs's application ID and rule ID, and the job service method name, for example:

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

By default, the command will start specified job and open the Job Progress dialog that will graphically show the job execution progress, and allow the user to stop the job.

You can use optional parameters to customize the command's behavior:

  • messageId : the ID of the <message> element in the AXVW file that contains the localized message that the Job Progress dialog will display.
  • resultView : the name of another AXVW file that will be displayed after the job execution is complete (replacing the current view).
  • useSingleJobView : if specified as true, the command will display the Single Job view instead of the Job Progress dialog. The Single Job view shows more detailed information about the job and provides additional options to the user.

Starting jobs from Java Script

You can also start jobs from the Java Script code, using the Workflow object. This lets you pass arbitrary parameters to jobs, and also to obtain the job ID that you can use later to check the job status.

Example:

try {
var dateFrom = ...;
var dateTo = ...;
var jobId = Workflow.startJob(" AbCommonResources-SpaceService-updateAreaTotalsSpaceTime ", dateFrom, dateTo);
} catch (e) {
Workflow.handleError(e);
}

You can use the obtained job ID to:

  • Display the Job Progress dialog:
    View.openJobProgressDialog(jobId);
  • Notify a Job Progress panel ( Ab.paginate.ProgressPanel ):
    this.progressPanelWrapper.onJobStarted(jobId);
  • Check the job status:
    var status = Workflow.getJobStatus(jobId);
  • Request the job to stop:
    Workflow.stopJob(jobId);
  • Terminate the job:
    Workflow.terminateJob(jobId);

Ab.paginate.ProgressPanel

Demonstrates the simplified JavaScript source code that uses the Ab.paginate.ProgressPanel class:

View: http://localhost:8080/archibus/schema/ab-products/solutions/programming/progress/ab-ex-progress-panel.axvw