Difference between revisions of "AddWatcherPerTicket"

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
m
 
Line 9: Line 9:
 
Custom Condition:
 
Custom Condition:
  
 +
<pre>
 
  return undef unless ( ($self-&gt;TransactionObj-&gt;Type eq "Create") ||
 
  return undef unless ( ($self-&gt;TransactionObj-&gt;Type eq "Create") ||
 
                       ( $self-&gt;TicketObj-&gt;FirstCustomFieldValue('Urgency') eq "High"));
 
                       ( $self-&gt;TicketObj-&gt;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-&gt;TicketObj-&gt;AddWatcher( Type =&gt; "Cc",
 
  $self-&gt;TicketObj-&gt;AddWatcher( Type =&gt; "Cc",
 
                               Email =&gt;"address\@email.com");
 
                               Email =&gt;"address\@email.com");
Line 24: Line 26:
 
       $self-&gt;TicketObj-&gt;QueueObj-&gt;Cc-&gt;MemberEmailAddresses );
 
       $self-&gt;TicketObj-&gt;QueueObj-&gt;Cc-&gt;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