SetCorresponderAsCC: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
(No difference)

Latest revision as of 15:37, 6 April 2016

Contributed by Fahd S.

Overview This custom action sets the corresponder as CC. A Queue is being worked on by a fixed group of support staff. The are all AdminCC and a template notifies them via email when a new ticket is created. The support staff replies/comments mostly via email. The problem was that no staff member was aware of what another staff member had replied b/c they never use the web interface. This scripts add all corresponders to CC to keep them abreast of updates to the ticket.

Description: SetCorresponderAsCC
Condition: On Correspond
Action: User Defined
Custom action preparation code:
 #uncomment Logger stuff for debuging
 #$RT::Logger->debug('Running Script TestScriptAddCC');

 my $Actor = $self->TransactionObj->Creator;
 my $Corresponder_id = $self->TransactionObj->CreatorObj->PrincipalId;
 my $OwnerEmail = $self->TicketObj->OwnerObj->EmailAddress();

 # exit if actor is RT_SystemUser
 return 1 if $Actor->id == $RT::SystemUser->id;


 # get out if corresponder is already requestor,cc or admincc.


 if ( $self->TicketObj->IsWatcher( Type => 'Requestor', PrincipalId => $Corresponder_id)  ){
     #$RT::Logger->debug("TestScriptAddCC - Corresponder is Requestor, exit");
     return 1;
 }

 if ( $self->TicketObj->IsWatcher( Type => 'Cc', PrincipalId => $Corresponder_id)  ){
     #$RT::Logger->debug("TestScriptAddCC - Corresponder is in CC, exit");
     return 1;
 }

 if ( $self->TicketObj->IsWatcher( Type => 'AdminCc', PrincipalId => $Corresponder_id)  ){
     #$RT::Logger->debug("TestScriptAddCC - Corresponder is in AdminCC, exit");
     return 1;
 }

 #RuslanZakirov's check
 my ($status, $msg) = $self->TicketObj->AddWatcher(
     Type => "Cc",
     PrincipalId => $Corresponder_id
 );

 unless ( $status ) {
     $RT::Logger->error("Couldn't add watcher: $msg");
 }

 return 1;

Template: Global template: Blank

Note: On rt-3.6.1, I had to use $Actor instead of $Actor->id.

Thanks to all those who contribute ....