Notification hooks trigger additional actions after a set of changes are committed to the database. For example, you can send an e-mail notification to one or more users or modify related records. Vous pouvez également créer une règle pour l'envoi des courriers électroniques. See Création de règles de messagerie électronique.)
You must stop and restart the Rational ClearQuest Mail Service every time you make changes to an e-mail notification hook.
The following example opens a window for each field in the defect that was modified. Vous pouvez également utiliser un crochet de notification pour générer un courrier électronique et l'envoyer à une liste de diffusion.
An action that is initiated from a hook does not trigger a notification unless you set the session variable CQHookExecute to a value of 1 in the hook script. This variable is a Long data type in VBScript and long scalar in Perl.
Sub swbug_Notification(actionname, actiontype)
' actionname As String
' actiontype As Long
' action = modify
' Remarque : N'utilisez pas MsgBox pour les bases de données Web
MsgBox "Modify action completed, notification hook started"
fieldnames = GetFieldNames
If IsArray(fieldnames) Then
I = LBound(fieldnames)
limit = UBound(fieldnames) + 1
' Obtenir trois sortes de valeurs
Do While I < limit
onename = fieldnames(I)
Set oldinfo = GetFieldOriginalValue(onename)
Set newinfo = GetFieldValue(onename)
oldstat = oldinfo.GetValueStatus
If oldstat = AD_HAS_NO_VALUE Then
oldempty = True
Else
oldempty = False
oldval = oldinfo.GetValue
End If
newstat = newinfo.GetValueStatus
If newstat = AD_HAS_NO_VALUE Then
newempty = True
Else
newempty = False
newval = newinfo.GetValue
End If
' Comparer les valeurs
If oldstat = AD_VALUE_UNAVAILABLE Then
MsgBox "Field " & onename & ": original value unknown"
Else
If newempty And Not oldempty Then
MsgBox "Field " & onename & " had its value deleted"
ElseIf oldempty And Not newempty Then
MsgBox "Field " & onename & " now= " & newval
ElseIf oldval <> newval Then
MsgBox "Field " & onename & " was= " & oldval
MsgBox "Field " & onename & " now= " & newval
Else
MsgBox "Field " & onename & " is unchanged"
End If
End If
I = I + 1
Loop
End If
MsgBox "Modify action and notification hook completed"
End Sub
sub swsub_Notification {
my($actionname, $actiontype) = @_;
# $actionname : scalaire de chaîne
# $actiontype : scalaire long
# action is Submit
# Possibilité de gérer ici les notifications post-validation
# relatives aux actions
my ($fieldnames,
$session,
$fieldname,
$oldinfo,
$newinfo,
$newstat,
$oldstat,
$oldval,
$oldempty,
);
$session=$entity->GetSession();
$fieldnames = $entity->GetFieldNames();
# Obtenir trois sortes de valeurs
foreach $fieldname (@$fieldnames) {
$oldinfo = $entity->GetFieldOriginalValue($fieldname);
$newinfo = $entity->GetFieldValue($fieldname);
$oldstat = $oldinfo->GetValueStatus();
if ($oldstat == $CQPerlExt::CQ_HAS_NO_VALUE) {
$oldempty = 1;
} else {
$oldempty = 0;
$oldval = $oldinfo->GetValue();
}
$newstat = $newinfo->GetValueStatus();
if ($newstat == $CQPerlExt::CQ_HAS_NO_VALUE) {
$newempty = 1;
} else {
$newempty = 0;
$newval = $oldinfo->GetValue();
}
# Comparer les valeurs
if ($oldstat == $CQPerlExt::CQ_VALUE_UNAVAILABLE) {
$session->OutputDebugString("Field " . $fieldname . ":
original value unknown\n");
} else {
if ($newempty && !$oldempty) {
$session->OutputDebugString ("Field " & $fieldname .
" had its value deleted\n");
} elsif ($oldempty && !$newempty) {
$session->OutputDebugString ("Field " . $fieldname . " now = " .
$newval. "\n");
} elsif ($oldval != $newval) {
$session->OutputDebugString ("Field " . $fieldname . " was = " .
$oldval. "\n");
$session->OutputDebugString ("Field " . $fieldname . " now = " .
$newval. "\n");
} else {
$session->OutputDebugString ("Field " . $fieldname . " is
unchanged\n");
}
}
}
$session->OutputDebugString ("Modify action & notification hook completed\n");
}