[rt-users] Mandatory Subject - EMail

Konstantin Khomoutov flatworm at users.sourceforge.net
Wed Sep 8 11:11:00 EDT 2010


On Wed, 8 Sep 2010 09:04:35 -0500
"Peter Barton" <PBarton at iesi.com> wrote:

> I have seen the RT-Extension-MandatorySubject plugin and this is
> great for opening tickets via the web interface.  However, my company
> opens at least 90% of its tickets via email.  Is there anything out
> that can enforce mandatory subjects on tickets opened via email?

We were facing the same problem (the difference is that in our case
100% tickets are filed using web interface) and it was solved using two
different soultions (deployed one after another, we're currently using
the first one).

The first is to make a scrip which sets the subject to the first
non-empty line of the report text.

Meta info for the scrip:
Description: "00 On Create Set Subject From Request Text"
Condition: User Defined
Action: User Defined
Template: Global Template: Blank
Stage: TransactionCreate

Scrip condition code:

if ($self->TransactionObj->Type eq 'Create'
    && $self->TicketObj->Subject() eq '') {
  return 1;
} else {
  return undef;
}

Scrip code:

my @lines = split(/\n/, $self->TransactionObj->Content());
for my $line (@lines) {
  $line =~ s/^\s+//;
  $line =~ s/\s+$//;
  if ($line ne '') {
    my ($ok, $msg) = $self->TicketObj->SetSubject($line);
    if (!$ok) {
      $RT::Logger->error("Failed to set ticket subject: $msg");
      return 0;
    }
    last;
  }
}
return 1;

The scrip description starts with "00 " to ensure it is executed
earlier that other scrips (see [1]) which is needed so that the
watchers of the relevant queue get their notification e-mail with
the subject appropriately modified.

Then we switched to using a callback for the BeforeCreate event of the
/SelfService/Create.html form and now the subject is set in that
callback using roughly the same code.

1. http://wiki.bestpractical.com/view/ScripExecOrder



More information about the rt-users mailing list