Triggering a task with the destination state

To apply some conditional logic, you can determine the destination state of the record currently undergoing an action. Here are some examples:

  • Send an e-mail to the Project Manager if a user moves a priority 1 defect into the "postponed" state.
  • Allow the user to modify (reapply the "opened" state) to a defect that is currently in the "resolved" state if, and only if, that user belongs to the Manager group.

The following action notification hook gets the destination state and sends an e-mail if the current record is being closed.

Note: This action notification hook uses a base action. A base action is an action that occurs with every action. A base action is convenient if you want a hook to fire with more than one action, such as an e-mail notification hook that fires with every action.

VBScript


Sub Defect_Notification(actionname, actiontype)

   Dim cqSes ' a Session object

   Dim entDef ' an EntityDef object

   Dim actionname ' a String

   Dim actiontype ' a Long

   ' action = test_base

   set cqSes = GetSession
   ' NOTE: You can also have conditional logic based on the
   ' current action

    set entDef = cqSes.GetEntityDef(GetEntityDefName)

    if entDef.GetActionDestStateName(actionName) = "Closed" then

       ' put send notification message code here

    end if

End Sub 

Perl


sub Defect_Notification {

    my($actionName, $actiontype) = @_;  

    # $actionName as string scalar

    # $actiontype as long scalar

    # action is test_base

   $actionName = $entity->GetActionName();
    # NOTE: You can also have conditional logic based on the
    # current action

  # You can use the $session variable that HCL Compass provides. 

    $entDef = session->GetEntityDef($entitiy->GetEntityDefName());

    if ($entDef->GetActionDestStateName($actionName) eq "Closed") 
      {# put send notification message code here}

}