Adding bcc

hi, i am using the following custom action preparation code i found on
the wiki. how do i do the same exact thing except for a bcc? and then
how do i create an action to notify bcc?

#uncomment Logger stuff for debuging
$RT::Logger->debug(‘Running Script ScriptAddCC’);

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 == $RT::SystemUser->id;

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

if ( $self->TicketObj->IsWatcher( Type => ‘Requestor’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is Requestor, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘Cc’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is in CC, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘AdminCc’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is in AdminCC, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘Owner’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is the ticket Owner, 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;

In RT, AdminCc translates to Bcc. Without doing any testing, I’d suggest
changing the section towards the end of the scrip to:

#RuslanZakirov’s check
my ($status, $msg) = $self->TicketObj->AddWatcher(
Type => “AdminCc”,
PrincipalId => $Corresponder_id
);

As for triggering an e-mail, you could put the code from the scrip into a
template and do it all in one place, or you could set some flag in the
ticket to trigger another scrip that does the template, or you could try
putting the guts of the code from the custom action into the condition area
and then make the action one of the Notify actions. If it was me, I’d
probably move the code into a custom template.

Regards,
Gene

At 07:42 AM 10/18/2007, slamp slamp wrote:

hi, i am using the following custom action preparation code i found on
the wiki. how do i do the same exact thing except for a bcc? and then
how do i create an action to notify bcc?

#uncomment Logger stuff for debuging
$RT::Logger->debug(‘Running Script ScriptAddCC’);

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 == $RT::SystemUser->id;

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

if ( $self->TicketObj->IsWatcher( Type => ‘Requestor’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is Requestor, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘Cc’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is in CC, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘AdminCc’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is in AdminCC, exit”);
return 1;
}

if ( $self->TicketObj->IsWatcher( Type => ‘Owner’, PrincipalId =>
$Corresponder_id) ){
$RT::Logger->debug(“ScriptAddCC - Corresponder is the ticket Owner,
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;


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Gene LeDuc, GSEC
Security Analyst
San Diego State University