[rt-users] Run order of Scrips / RT 3.6.3

Ham MI-ID, Torsten Brumm torsten.brumm at Kuehne-Nagel.com
Fri Jul 13 04:33:54 EDT 2007


Hi RT Users,

i'm just fighting with a scrip exec order. So far i remember, we can
fire up scrips from UI in a sort order (beginning from 3.6.0??)

No i have the problem that i need at create time 3 actions to be done.

There are no global Scrips defined, only on this queue.

>From the flow:

A new mail reaches this queue, then:

1. Set a CF (PM) to a default value (Value = ?)
2. Parse the incoming mail for a specific value and put this into CF
(PM)
3. Send mail to AdminCC's with modified Subject line with the Content of
PM

All this scrips are triggering OnCreate, but now funny things start, the
mail sent to the AdminCC's are fired before the other Scrips are
running.

My Scrips look like this:


Scrip 1:

001_SetDefaultValueForPM (On Create User Defined with template Blank)

Custom Action Prep Code: return 1;
Custom Action Cleanup Code:

  my $CFName = 'PM';
  my $DefaultValue = 'PM?';
  my $RecTransaction = 1;

  my $QueueObj = $self->TicketObj->QueueObj;
  my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
  $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => $QueueObj->id );
  unless( $CFObj->id ) {
    $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => 0 );
    unless( $CFObj->id ) {
      $RT::Logger->warning("custom field '$CFName' isn't global or
defined for queue '". $QueueObj->Name ."'");
      return undef;
    }
  }

  unless( $self->TicketObj->FirstCustomFieldValue( $CFObj->id ) ) {
    my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue(
                                          Field => $CFObj->id,
                                          Value => $DefaultValue,
                                          RecordTransaction =>
$RecTransaction );
    unless( $st ) {
      $RT::Logger->warning( "Couldn't set $DefaultValue as value for CF
$CFName:". $msg );
      return undef;
    }
  }
  return 1;

Scrip 2:

002_ScanForPM (On Create Extract Custom Field Values with template
ScanForPM)

Template: ScanForPM
Content: PM|Body|#(PM\w+)#||q


Scrip 3:

999_InformAdminCC (On Create Notify AdminCcs with template
CreateNewTicket)

Template: CreateNewTicket

Content: 

Subject: #{$Ticket->FirstCustomFieldValue('PM');}# {$Ticket->Subject}
RT-Attach-Message: yes

{$Transaction->Content()}


Each Scrip alone works well, but all together working but not like
expacted. Any Ideas? What's wrong with this?

Help needed ;-)

Thanks

Torsten



More information about the rt-users mailing list