ConcourseSuite Support

Support
Corporate
PUBLIC PROFILE

processInsertHook()

The methods processInsertHook(), processUpdateHook(), and processDeleteHook() are used to trigger workflow processes.

Trigger Workflow Manager During Object Insert

The following Module Action Class code shows that when an object is inserted, the workflow manager is notified, whether there are workflow processes defined to execute on this object or not.

// Retrieve ticket from request
Ticket ticket = (Ticket) context.getFormBean();
// Set server side properties
ticket.setEnteredBy(getUserId(context));
ticket.setModifiedBy(getUserId(context));
boolean isValid = validateObject(context, db, ticket);
if (isValid) {
  boolean recordInserted = ticket.insert(db);
  if (recordInserted) {
    // Trigger the workflow manager
    processInsertHook(context, ticket);
  }
}

Trigger Workflow Manager During Object Update

The following Module Action Class code shows that when an object is updated, the workflow manager is notified, whether there are workflow processes defined to execute on this object or not.

// Retrieve ticket from request
Ticket ticket = (Ticket) context.getFormBean();
// Set server side properties
ticket.setModifiedBy(getUserId(context));
boolean isValid = validateObject(context, db, ticket);
if (isValid) {
  // Load the previous ticket for comparison
  Ticket previousTicket = new Ticket(db, ticket.getId());
  int resultCount = ticket.update(db);
  if (resultCount == 1) {
    // Get the updated ticket details
    ticket.queryRecord(db, ticket.getId());
    // Trigger the workflow manager
    processUpdateHook(context, previousTicket, ticket);
  }
}

Trigger Workflow Manager During Object Deletion

The following Module Action Class code shows that when an object is deleted, the workflow manager is notified, whether there are workflow processes defined to execute on this object or not.

// Load the ticket, given a ticket id
Ticket ticket = new Ticket(db, id);
// Attempt to delete the ticket and any associated ticket documents
boolean recordDeleted = ticket.delete(db, getDbNamePath(context));
if (recordDeleted) {
  // Trigger the workflow manager
  processDeleteHook(context, ticket);
}

Sign in to add your comment.