[rt-users] A couple Scrips to share.

Edge, Sean Sean.Edge at mtvnmix.com
Fri Jun 15 16:09:04 EDT 2007


We would like to share the following Scrips with the community.  They
all set the status of a ticket back to open and log a comment if certain
conditions were not met prior to Ticket resolution.  The first ensures
that Time Worked was recorded, the second requires ownership to be
taken, and the third checks to make sure that at least one of two
CustomFields has been set.  We only wanted them enabled for certain
queues so instead of creating a new Scrip per queue we created a global
Scrip that compares the Queue first.

All three have the same dropdown config options:
Condition: On Resolve
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

All three also have "return 1;" for the Custom Action Cleanup Code and
obviously the Condition (which isn't user defined anyway).

Description: NoTimeWorked
-----
# Only do it for certain queues.
my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);
my $queue_id = $self->TicketObj->Queue;
my $val = grep { /^${queue_id}$/ } @queues;
if ($val) {
  if ((! defined($self->TicketObj->TimeWorked)) ||
    ($self->TicketObj->TimeWorked == 0)) { 
    my ($id, $msg) = $self->TicketObj->SetStatus("open");
    $self->TicketObj->Comment(Content => "You must set the Time
Worked!");
  }
}
return 1;
-----

Description: ResolvedByNobody
-----
# Only do it for certain queues.
my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);
my $queue_id = $self->TicketObj->Queue;
my $val = grep { /^${queue_id}$/ } @queues;
if ($val) {
  if ((! defined($self->TicketObj->Owner)) || 
    ($self->TicketObj->Owner == RT::Nobody->id)) { 
    my ($id, $msg) = $self->TicketObj->SetStatus("open");
    $self->TicketObj->Comment(Content => "You must take ownership to
resolve this ticket!");
  }
}
return 1;
-----

Description: SetSiteORDept
-----
my $cf_site = $self->TicketObj->CustomFieldValues(1);
my $cf_dept = $self->TicketObj->CustomFieldValues(9);
# Only do it for certain queues.
my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);
my $queue_id = $self->TicketObj->Queue;
my $val = grep { /^${queue_id}$/ } @queues;
if ($val) {
  if (($cf_site->Count == 0) && ($cf_dept->Count == 0)) { 
    my ($id, $msg) = $self->TicketObj->SetStatus("open");
    $self->TicketObj->Comment(Content => "You must set select at least
one Site or one Department!");
  }
}
return 1;
-----


Unfortunately I haven't yet figured out, or put much time recently, how
to ensure that the actions are reflected in the Results Callback at the
top.  That will also explain why I captured the transaction id/msg when
setting the status and never used them.  I toyed with the idea of
creating my own Transaction but heeded the warning in
Transaction_Overlay.pm.  If anyone knows how to do what I'm talking
about please let me know!  =)

Also, apparently trying to set the Ownership (via Jumbo or the Resolve
link) and possibly the CustomFields during resolution causes the actions
to fail.  In other words, if the user first sets all the appropriate
fields and THEN goes back and resolves the ticket everything should be
fine.

Enjoy!  Hopefully someone will find these useful!


-----
Sean Edge
Consultant
MTV Networks



This email (including any attachments) is for its intended-recipient's
use only. This email may contain information that is confidential or
privileged.  If you received this email in error, please immediately
advise the sender by replying to this email and then delete this message
from your system.  For further information and disclaimers that apply to
this email, see [http://www.viacom.com/email_disclaimer.jhtml].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20070615/6548b5d9/attachment.htm>


More information about the rt-users mailing list