[rt-users] Grouping Custom Fields

Ian Petts ipetts at gmail.com
Wed Nov 21 17:02:01 EST 2007


Hi Kenn,

> I don't have an answer for you, but YOU have one for me. You mentioned
> a scrip that allows "RT to re-open a ticket" if certain fields/values
> meet a condition. I have need of just such a scrip.

The scrip(s) I based mine off were found here:
http://www.gossamer-threads.com/lists/rt/users/66169?search_string=sean.edge;#66169

The scrip I ended up with is:

===== 8< =====
# Enable for Testing:
#exit 1 unless ($self->TransactionObj->CreatorObj->Name eq "ian");

use constant FALSE => 0;
use constant TRUE  => 1;

my @mandatory_fields = ('Procedures Updated', 'Network Diagrams Updated',
'Monitoring Enabled');

my $comment = "Please ensure all compulsory fields are completed.";
my $ok = TRUE;

foreach my $field (@mandatory_fields) {
 $ok = FALSE unless (defined $self->TicketObj->FirstCustomFieldValue($field));
}

unless ($ok) {
 my ($id, $msg) = $self->TicketObj->SetStatus("open");
 $self->TicketObj->Comment(Content => $comment);
}

return 1;
===== >8 =====

> Being a 'PERL' novice, I try to gather as many scrips that are models of various
> conditions/actions as I can for reference as I build my own.

I can sympathize. My perl is fairly basic as well, as the more
experienced programmers will tell you after looking at the above  :-)

This code seems to work for me, however I plan on making a few mods
today to clean things up a little. Firstly, the ticket gets re-opened,
but it is not assigned to anyone. I need to work out how to assign it
back to the person who closed it. Secondly, I'll be changing the
mandatory_fields list to a hash, as since I wrote this I learned that
it's much faster and more efficient to look for keys of a hash than to
loop around a list like I'm doing above - see
http://faq.perl.org/perlfaq4.html#How_can_I_tell_wheth

I hope this helps!

Regards,
Ian.



More information about the rt-users mailing list