Hello all,
It’s been a while since I’ve been on here, mostly because I never got email list mode to work. But I’m stuck on Perl in a script and don’t know what I’m doing wrong, mostly because I don’t know enough Perl to see the problem.
I want a script to make one-time CCs added on a ticket transaction into permanent ones. I’ve learned enough from the docs that I took a stab at making this script, but the log says that said script can’t be “prepared”. I take this to mean I have a syntax error somewhere. I’ll paste the script below, but let me briefly outline what I’m going for and what I think I know.
I first get the one-time CCs by asking for the “RT-Send-CC” list in the associative array returned by $self->TransactionObj->Addresses. I then get the array of one-time CCs by asking for the ticket’s CC group, I combine the two arrays into a third, remove duplicates, then set the whole thing as the ticket’s CC list. At least, that’s what I’m trying to do. Where did I go wrong? Thanks in advance.
#get any 1-time CC addresses in this transaction
my @oneTimeCCAddresses = $Self->TransactionObj->Addresses{RT-Send-Cc};
return undef unless $oneTimeCCAddresses > 0; #exit if no 1-time CCs were set
#now get this ticket's CC addresses
my @ticketCCAddresses = $self->TicketObj->Cc->UserMembersObj;
my @allCCAddresses = (@oneTimeCCAddresses, @ticketCCAddresses);
#remove duplicates, thanks to post 3 on
#http://www.unix.com/shell-programming-and-scripting/90537-how-remove-duplicate-sentence-string-perl.html
grep !$_{$_}++, @allCCAddresses
#add all these emails as watchers
my $newWatcher;
while ($newWatcher = $allCCAddresses->next) {
my ($status, $msg) = $self->TicketObj->AddWatcher($newWatcher);
}
return 1;