[Rtir] Re: Blocks

Gorazd Bozic gorazd.bozic at arnes.si
Thu Jul 28 04:11:19 EDT 2005


Rodney Tillotson wrote:
> 
> I can't even see how to reach the 'removed' state manually. My
> workaround is to resolve the enclosing Incident and then re-open any
> other child tickets that I still want to work with.
> 
> I've no idea where it is implemented.

We have a Scrip in a Block Queue, which is called "Activate or Remove
Block" (I've posted something similar to the list in Mar 2004). The
problem is that for some reason it works only for block activation.
Here's the code:

Description: Activate or Remove Block
Condition: On Correspond
Custom Condition:
Action: User Defined
Custom action preparation code: 1
Custom action cleanup code:
# ------------------------------------------------------------------- #
my $State;
my $cf = RT::CustomField->new($self->TransactionObj->CurrentUser);
$cf->LoadByNameAndQueue(Queue => $self->TicketObj->QueueObj->Id,
                        Name => '_RTIR_State');
unless ($cf->Id) {
    return(1);
}

my @content = @{$self->TransactionObj->MIMEObj->body};
if (scalar(grep(/^[^>]*\*OK\*/, @content)) > 0) {
  if ($cf->Name eq 'pending activation') { $State = 'active'; }
  elsif ($cf->Name eq 'pending removal') { $State = 'removed'; }
  else { return 0; }
} else {
  return 0;
}
$self->TicketObj->AddCustomFieldValue(Field => $cf->id,
                                      Value => $State);
if ($State eq 'removed') { $self->TicketObj->Resolve(); }
return 1;
# ------------------------------------------------------------------- #
Stage: Transaction Create
Template: Global Template: Blank

When we get a reply with a string "*OK*", state "pending activation"
changes to "active", while transition from "pending removal" to
"removed" doesn't work for some reason. My guess is that since these
states are actually derived from generic states in SetRTIRState scrip:

if ($self->TicketObj->Status eq 'new') {
  $State = 'pending activation';
} elsif (($self->TicketObj->Status eq 'open') &&
         ($cf->Name ne 'pending removal')) {
  $State = 'active';
} elsif ($self->TicketObj->Status eq 'stalled') {
  $State = 'pending removal';
} elsif ($self->TicketObj->Status eq 'resolved') {
  $State = 'removed';
} else {
  return 0;
}

a correspondence causes the ticket to go from "stalled" (="pending
removal") to "open" (="active"), before our scrip "Activate or Remove
Block" kicks in. Amongst the scrips that apply to all queues is one
called "On Correspond Open Tickets with template Blank".

I guess what is needed is to modify this global scrip and add a custom
condition that checks whether the ticket's queue is "Blocks" and return
0, else 1... I'll try that and report back on the list.

Regards,
Gorazd

-- 
Gorazd Bozic <gorazd.bozic at arnes.si>
ARNES SI-CERT, Jamova 39 p.p. 7, SI-1001 Ljubljana, Slovenia
tel: +386 1 479 88 22, fax: +386 1 479 88 99


More information about the Rtir mailing list