AddWatcherPerTicket: Difference between revisions
m (2 revisions imported) |
mNo edit summary |
||
Line 9: | Line 9: | ||
Custom Condition: | Custom Condition: | ||
<pre> | |||
return undef unless ( ($self->TransactionObj->Type eq "Create") || | return undef unless ( ($self->TransactionObj->Type eq "Create") || | ||
( $self->TicketObj->FirstCustomFieldValue('Urgency') eq "High")); | ( $self->TicketObj->FirstCustomFieldValue('Urgency') eq "High")); | ||
return 1; | return 1; | ||
</pre> | |||
Action: User Defined | Action: User Defined | ||
Line 18: | Line 19: | ||
Custom action preparation code: | Custom action preparation code: | ||
<pre> | |||
$self->TicketObj->AddWatcher( Type => "Cc", | $self->TicketObj->AddWatcher( Type => "Cc", | ||
Email =>"address\@email.com"); | Email =>"address\@email.com"); | ||
Line 24: | Line 26: | ||
$self->TicketObj->QueueObj->Cc->MemberEmailAddresses ); | $self->TicketObj->QueueObj->Cc->MemberEmailAddresses ); | ||
return 1; | return 1; | ||
</pre> | |||
Custom action cleanup code: | Custom action cleanup code: |
Latest revision as of 14:47, 14 August 2016
You can use this Scrip to add a Watcher to a particular ticket. One possible use would be to have tickets of a particular urgency (as in the custom condition below) forwarded to an 'emergency' email address, or to someone's phone via an email-SMS gateway.
Note that you need to set up two scrips for this: the first to add the extra Watcher, and the second to send the email. This is because of the order in which RT runs through its automatic & user-defined actions.
First scrip
Condition: User Defined
Custom Condition:
return undef unless ( ($self->TransactionObj->Type eq "Create") || ( $self->TicketObj->FirstCustomFieldValue('Urgency') eq "High")); return 1;
Action: User Defined
Custom action preparation code:
$self->TicketObj->AddWatcher( Type => "Cc", Email =>"address\@email.com"); push( @{$self->{'To'}}, $self->TicketObj->Requestors->MemberEmailAddresses, $self->TicketObj->QueueObj->Cc->MemberEmailAddresses ); return 1;
Custom action cleanup code:
1;
Template: Global Template: Transaction
Second scrip
Condition: On Create
Action: Notify Ccs
Template: Global Template: Transaction
- I had problems with scrip order to get this to work. The Notify scrip has to be executed after the Add CC scrip. See ScripExecOrder
See also: ManualScrips, WriteCustomAction, WriteCustomCondition