WorkflowModelManager - Global

The WorkflowModelManager class provides a way to query the workflow model, to step backwards and forwards between specified wf_history items, and to query the history for activity and transition-specific information.

The interaction with the WorkflowModelManager class is through the ActivityHistoryRecord data object. The ActivityHistoryRecord is an inner class and is only used while interacting with WorkflowModelManager.

To acquire the executed history of the workflow activities:
var model = new WorkflowModelManager('myContextId');
var activities = model.getExecutedHistory();
To output the playback of the workflow:
var model = new WorkflowModelManager('myContextId');
model.getExecutedHistory();
model.playBack();

At this time, the playBack is required to load the executed transitions. This will also play a role in walking backwards on a model to rollback to a specific activity.

To see the details of the cached model:
var model = new WorkflowModelManager('myContextId');
 model.getExecutedHistory();
 model.dump();

WorkflowModelManager - getActivityHistoryRecordById(String haRecordSysId)

Retrieves the history activity that is cached by the wf_history.sys_id provided in the argument.

Table 1. Parameters
Name Type Description
haRecordSysId String The sys_id of the activity history (table wf_history).
Table 2. Returns
TypeDescription
ActivityHistoryRecordThe ActivityHistoryRecord JavaScript object requested.

WorkflowModelManager - getAllTransitionedIntoActivity(Object description)

Retrieves the history activities that executed and transitioned into the one represented by the sys_id in the argument. The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that executed in the workflow's history. (This differs from getPreviousByTransition, which only returns TO transitions that come before the haRecord in the execution sequence (by time).) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on all transitions in the executed history collection that transition To get the activity that executed prior to this activity in time use getPreviousByExecutedOrder.

The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that executed in the workflow's history. (This differs from getPreviousByTransition, which only returns TO transitions that come before the haRecord in the execution sequence (by time).) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on all transitions in the executed history collection that transition To get the activity that executed prior to this activity in time use getPreviousByExecutedOrder.

Table 3. Parameters
Name Type Description
description Object ActivityHistoryRecord JavaScript object.
Table 4. Returns
TypeDescription
Object ArrayArray of ActivityHistoryRecord JavaScript objects.

WorkflowModelManager - getAllTransitionedIntoActivityId(String haRecordSysId)

Retrieves the history activities that executed and transitioned into the one represented by the sys_id in the argument. The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that executed in the workflow's history. (This differs from getPreviousByTransition, which returns only TO transitions that come before the haRecord in the execution sequence (by time).) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity.

The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that executed in the workflow's history. (This differs from getPreviousByTransition, which returns only TO transitions that come before the haRecord in the execution sequence (by time).) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity.

Table 5. Parameters
Name Type Description
haRecordSysId String The sys_id of the activity history (table wf_history).
Table 6. Returns
TypeDescription
Object ArrayArray of ActivityHistoryRecord JavaScript objects requested.

var model = new WorkflowModelManager('a143585c3b001000dada82c09ccf3d44');
      model.getExecutedHistory();
      var activity = model.begin;
      gs.print('activity: ' + activity.wfaName + ', transitions: ' + activity.transitions.length);
      while( activity != null){    
          gs.print('activity: ' + activity.wfaName + ', transitions: ' + activity.transitions.length);    
          var parents = model.getAllTransitionedIntoActivity(activity);
          for( var i = 0; i < parents.length; i++ ){
              gs.print(' ---------------  parent activity: ' + parents[i].wfaName );
            }
           activity = model.getNextByExecutedOrder( activity );
      }
    

WorkflowModelManager - getExecutedHistory( )

This is the worker method that must be called to initialize the WorkflowModelManager object. In the process of initializing the WorkflowModelManager object, getExecutedHistory() creates and populates the activityHistoryRecord data object array (which is a member of the WorkflowModelManager class). Most WorkflowModelManager methods return a subset of the activityHistoryRecord array. Your script can then call one or more of the activityHistoryRecord methods to accomplish further work.

Table 7. Parameters
Name Type Description
None
Table 8. Returns
TypeDescription
String ArrayAn ordered array of sys_ids from table wf_history. It is unlikely client code would use the return value; it is kept internally to this object for use by subsequent method calls.

var model = new WorkflowModelManager('myContextId');
var activities = model.getExecutedHistory();
var current = model.getActivityHistoryRecordById('d6681d573b130000dada82c09ccf3d10');

WorkflowModelManager - getFinalExecutedActivityList( )

Queries the wf_history table by context and retrieves all the activities executed in the workflow given by the context set in the construction of this object. This function produces a list of executed activities in the exact order each activity passed through the server side ActivityManager.java using the new activity_index to force the order coming out of the database. On its this call will not give the full picture; it needs to load and map the transitions.

This function produces a list of executed activities in the exact order each activity passed through the server side ActivityManager.java using the new activity_index to force the order coming out of the database. On its this call will not give the full picture; it needs to load and map the transitions.

Table 9. Parameters
Name Type Description
None
Table 10. Returns
TypeDescription
Object Array Array of ActivityHistoryRecord javascript objects.

WorkflowModelManager - getFinalExecutedActivityIdList( )

Gets the list of wf_history.sys_ids of all activities that successfully executed and were not rolled back or skipped up to the moment the function was called.

Table 11. Parameters
Name Type Description
None
Table 12. Returns
TypeDescription
String Array Array of wf_history.sys_id values for executed activities.

var model = new WorkflowModelManager('ee3e0a053b101000dada82c09ccf3d7c');
      model.getExecutedHistory();
      var finals = model.getFinalExecutedActivityIdList();
      gs.print(' EXECUTION PATH IDs --------------- : '  + finals.length);
      
      for ( var x = 0; x < finals.length; x++ ) {
          gs.print(finals[x] );
      }

WorkflowModelManager - getNextByExecutedOrder(Object haRecord)

Retrieves the history activity that executed just after to the one provided in the argument. The next status is based on the activity index reflecting the nearest prior activity in time and not necessarily the nearest next wf_activity the provided activity transitioned to. To get the nearest next activity that transitioned to this haRecord passed in, use getNextByTransitionOrder( haRecord ). Note: In the process of assembling the execution order array, blanks are left in the array where history objects have been deleted. This is done to ensure the index in the array and the activity_index of the object remain in synch. For that reason, all objects coming out of the execution order array should be tested for nil() and not assumed to be the previous record based on activity_index or array index value alone.

The next status is based on the activity index reflecting the nearest prior activity in time and not necessarily the nearest next wf_activity the provided activity transitioned to. To get the nearest next activity that transitioned to this haRecord passed in, use getNextByTransitionOrder( haRecord ).
Note: In the process of assembling the execution order array, blanks are left in the array where history objects have been deleted. This is done to ensure the index in the array and the activity_index of the object remain in synch. For that reason, all objects coming out of the execution order array should be tested for nil() and not assumed to be the previous record based on activity_index or array index value alone.
Table 13. Parameters
Name Type Description
haRecord Object ActivityHistoryRecord JavaScript object.
Table 14. Returns
TypeDescription
ObjectThe ActivityHistoryRecord JavaScript object requested.

WorkflowModelManager - getNextByExecutedOrderId(String haRecordSysId)

Retrieves the history activity that is cached by the wf_history.sys_id provided in the argument and then calls into getNextByExecutedOrder() with the retrieved JavaScript object.

Table 15. Parameters
Name Type Description
haRecordSysId String The sys_id of the activity history (table wf_history).
Table 16. Returns
TypeDescription
ObjectThe ActivityHistoryRecord JavaScript object requested.

var model = new WorkflowModelManager('7b3e01573b130000dada82c09ccf3dcf');
      model.getExecutedHistory();
      var current = model.getActivityHistoryRecordById('d6681d573b130000dada82c09ccf3d10');
      current.debugDump();
      
      var results = model.getNextByExecutedOrderId(current.sys_id);
      results.debugDump();

WorkflowModelManager - getNextByTransitionId(String haRecordSysId)

Retrieves the history activity that executed just after to the one identified by the sys_id provided in the argument. This function retreives the cached history record associated with the provided wf_history.sys_id and then calls getNextByTransition. The return values are based on which transitions came before the haRecord submitted and not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time, use getNextByExecutedOrder.

This function retreives the cached history record associated with the provided wf_history.sys_id and then calls getNextByTransition. The return values are based on which transitions came before the haRecord submitted and not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time, use getNextByExecutedOrder.

Table 17. Parameters
Name Type Description
haRecordSysId String sys_id of the activity history (table wf_history).
Table 18. Returns
TypeDescription
Object ArrayArray of ActivityHistoryRecord JavaScript objects.

var model = new WorkflowModelManager('7b3e01573b130000dada82c09ccf3dcf');
      model.getExecutedHistory();
      model.playBack();
      
      var current = model.getActivityHistoryRecordById('d6681d573b130000dada82c09ccf3d10');
      current.debugDump();
      var results = model.getNextByTransitionId(current.sys_id);
      gs.print('COMPLETED NEXT' + results.length );
      for( var i = 0; i < results.length; i++){
          results[i].debugDump();
      }

WorkflowModelManager - getPreviousByExecutedOrder(Object haRecord)

Retrieves the history activity that executed just previous to the one provided in the argument. The previous status is based on the activity index reflecting the nearest prior activity in time and not necessarily the nearest prior activity with a valid transition to this activity. To get the nearest prior activity that transitioned to this haRecord passed in use getPreviousByTransition( haRecord). Note: In the process of assembling the execution order array, blanks are left in the array where history objects have been deleted. This ensures that the index in the array and the activity_index of the object remain in sync. For that reason, all objects coming out of the execution order array should be tested for nil() and not assumed to be the previous record based on activity_index or array index value.

The previous status is based on the activity index reflecting the nearest prior activity in time and not necessarily the nearest prior activity with a valid transition to this activity. To get the nearest prior activity that transitioned to this haRecord passed in use getPreviousByTransition( haRecord).
Note: In the process of assembling the execution order array, blanks are left in the array where history objects have been deleted. This ensures that the index in the array and the activity_index of the object remain in sync. For that reason, all objects coming out of the execution order array should be tested for nil() and not assumed to be the previous record based on activity_index or array index value.
Table 19. Parameters
Name Type Description
haRecord Object ActivityHistoryRecord JavaScript object
Table 20. Returns
TypeDescription
ObjectThe ActivityHistoryRecord JavaScript object requested.

WorkflowModelManager - getPreviousByExecutedOrderId(String haRecordSysId)

Retrieves the history activity cached by the wf_history.sys_id provided in the argument, then calls getPreviousByExecutedOrder() with the retrieved JavaScript object.

Table 21. Parameters
Name Type Description
haRecordSysId String Workflow history system ID (wf_history.sys_id)
Table 22. Returns
TypeDescription
ActivityHistoryRecordThe ActivityHistoryRecord JavaScript object requested.

var model = new WorkflowModelManager('contextId');
      model.getExecutedHistory();
      var current = model.getActivityHistoryRecordById('wf_history.sys_id');
      current.debugDump();
      
      var results = model.getPreviousByExecutedOrderId(current.sys_id);
      results.debugDump();

WorkflowModelManager - getPreviousByTransitionId(String haRecordSysId)

Retrieves the history activities that executed just prior to the one provided in the argument. The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that come before the haRecord in the execution sequence. The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on which transitions came before the haRecord sumbitted and not not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time use getPreviousByExecutedOrder.

The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that come before the haRecord in the execution sequence. The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on which transitions came before the haRecord sumbitted and not not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time use getPreviousByExecutedOrder.

Table 23. Parameters
Name Type Description
haRecordSysId String The sys_id of the activity history (table wf_history).
Table 24. Returns
TypeDescription
ObjectArray of ActivityHistoryRecord JavaScript objects requested.

WorkflowModelManager - getPreviousByTransition(Object haRecord)

Retrieves the history activities that executed just prior to the one provided in the argument. The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that come before the haRecord in the execution sequence. (This differs from getAllTransitionedIntoActivity, which returns all TO transitions up to the given haRecord in the execution sequence .) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on which transitions came before the haRecord submitted and not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time, use getPreviousByExecutedOrder.

The next status is based on the wf_activity.sys_id associated with the activity represented in the haRecord existing as a TO in a transition associated with any ActivityHistoryRecords that come before the haRecord in the execution sequence. (This differs from getAllTransitionedIntoActivity, which returns all TO transitions up to the given haRecord in the execution sequence .) The return value is a collection of ActivityHistoryRecords that identify the argument haRecord.wfaId as their TO activity. The return values are based on which transitions came before the haRecord submitted and not necessarily the activities that executed just prior to the haRecord in time. To get the activity that executed prior to this activity in time, use getPreviousByExecutedOrder.

Table 25. Parameters
Name Type Description
haRecord Object ActivityHistoryRecord JavaScript object.
Table 26. Returns
TypeDescription
Object Array Array of ActivityHistoryRecord JavaScript objects requested.

WorkflowModelManager - WorkflowModelManager(String contextId)

Creates a new WorkflowModelManager object (constructor) within the specified context.

Table 27. Parameters
Name Type Description
contextId String The ID for the context in which you want the WorkflowModelManager created.
Table 28. Returns
TypeDescription
ActivityHistoryRecordThe ActivityHistoryRecord JavaScript object requested.

var model = new WorkflowModelManager('MyContextId');