Using Keywords in Scrips

Hi there,

I’d like to be able to make use of the keywords that I have set in a
queue and use whatever is set in a scrip.

More specifically, I’d like to be able to add the first keyword that
appears for the ticket to the subject line to get something like:

[rtname #22] [support] Rest of the subject line here.

I’ve taken a look at what documentation there is on scrips, as well as
the various database schemas, yet can’t work out how to do this.
Certainly, I’m guessing that this is not exactly a simple matter, and
will no doubt require coding in the scrip. I could do with a pointer on
how to do this, or has anyone done this?

Thanks,
J C Doran
fox@vulpes.net

I’d like to be able to make use of the keywords that I have set in a
queue and use whatever is set in a scrip.

More specifically, I’d like to be able to add the first keyword that
appears for the ticket to the subject line to get something like:

‘first’ is unreliable when multiple keywords can be applied to a ticket.

[rtname #22] [support] Rest of the subject line here.

I have the following snippet in my correspondence template, to end up with
headers such as:

X-RT-Keyword: Magic keyword

You could change this to add a particular keyword to the subject line.

Something like this should probably be a KeywordsAsString method in
RT::Ticket.

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B             Operations/Security

{ my $retval = undef; my $keywdsels = $Ticket->QueueObj->KeywordSelects;
while( my $keywdsel = $keywdsels->Next() ){ my $keywds =
$Ticket->KeywordsObj( $keywdsel->Id ); while( my $keywd = $keywds->Next()
){ $retval .= "X-RT-Keyword: " . $keywd->KeywordObj->RelativePath(
$keywdsel->KeywordObj ) . “\n”; } } chomp( $retval ); $retval }

I’d like to be able to make use of the keywords that I have set in a
queue and use whatever is set in a scrip.

More specifically, I’d like to be able to add the first keyword that
appears for the ticket to the subject line to get something like:

‘first’ is unreliable when multiple keywords can be applied to a ticket.

[rtname #22] [support] Rest of the subject line here.

I have the following snippet in my correspondence template, to end up with
headers such as:

X-RT-Keyword: Magic keyword

You could change this to add a particular keyword to the subject line.

Something like this should probably be a KeywordsAsString method in
RT::Ticket.

I guess that if I know the particular Id I want from KeywordSelects, I
could use it in a per-queue template.

However, I tried this snippet and put it as my correspond template
(neatening out the formatting a little), but I see no sign of the header
in the mail that is sent out at all.

Right now, my correspond template looks as follows:

{
my $retval = undef;
my $keywdsels = $Ticket->QueueObj->KeywordSelects;
while ( my $keywdsel = $keywdsels->Next() )
{
my $keywds = $Ticket->KeywordsObj( $keywdsel->Id );
while( my $keywd = $keywds->Next() )
{
$retval .= "X-RT-Keyword: " .
$keywd->KeywordObj->RelativePath($keywdsel->KeywordObj ) .
“\n”;
}
}
chomp( $retval );
$retval
}

{$Transaction->Content()}

Am I missing something somewhere?

Thanks,

However, I tried this snippet and put it as my correspond template
(neatening out the formatting a little), but I see no sign of the header
in the mail that is sent out at all.

[much snippery]

$retval
 $retval;

}

{$Transaction->Content()}

Am I missing something somewhere?

Just a wee ‘;’, happens to all of us :wink:

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B             Operations/Security