<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>A couple Scrips to share.</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">All three have the same dropdown config options:</FONT>

<BR><FONT SIZE=2 FACE="Arial">Condition: On Resolve</FONT>

<BR><FONT SIZE=2 FACE="Arial">Action: User Defined</FONT>

<BR><FONT SIZE=2 FACE="Arial">Template: Global template: Blank</FONT>

<BR><FONT SIZE=2 FACE="Arial">Stage: TransactionCreate</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">All three also have "return 1;" for the Custom Action Cleanup Code and obviously the Condition (which isn't user defined anyway).</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Description: NoTimeWorked</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>

<BR><FONT SIZE=2 FACE="Arial"># Only do it for certain queues.</FONT>

<BR><FONT SIZE=2 FACE="Arial">my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $queue_id = $self->TicketObj->Queue;</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $val = grep { /^${queue_id}$/ } @queues;</FONT>

<BR><FONT SIZE=2 FACE="Arial">if ($val) {</FONT>

<BR><FONT SIZE=2 FACE="Arial">  if ((! defined($self->TicketObj->TimeWorked)) ||</FONT>

<BR><FONT SIZE=2 FACE="Arial">    ($self->TicketObj->TimeWorked == 0)) { </FONT>

<BR><FONT SIZE=2 FACE="Arial">    my ($id, $msg) = $self->TicketObj->SetStatus("open");</FONT>

<BR><FONT SIZE=2 FACE="Arial">    $self->TicketObj->Comment(Content => "You must set the Time Worked!");</FONT>

<BR><FONT SIZE=2 FACE="Arial">  }</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>

<BR><FONT SIZE=2 FACE="Arial">return 1;</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Description: ResolvedByNobody</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>

<BR><FONT SIZE=2 FACE="Arial"># Only do it for certain queues.</FONT>

<BR><FONT SIZE=2 FACE="Arial">my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $queue_id = $self->TicketObj->Queue;</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $val = grep { /^${queue_id}$/ } @queues;</FONT>

<BR><FONT SIZE=2 FACE="Arial">if ($val) {</FONT>

<BR><FONT SIZE=2 FACE="Arial">  if ((! defined($self->TicketObj->Owner)) || </FONT>

<BR><FONT SIZE=2 FACE="Arial">    ($self->TicketObj->Owner == RT::Nobody->id)) { </FONT>

<BR><FONT SIZE=2 FACE="Arial">    my ($id, $msg) = $self->TicketObj->SetStatus("open");</FONT>

<BR><FONT SIZE=2 FACE="Arial">    $self->TicketObj->Comment(Content => "You must take ownership to resolve this ticket!");</FONT>

<BR><FONT SIZE=2 FACE="Arial">  }</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>

<BR><FONT SIZE=2 FACE="Arial">return 1;</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Description: SetSiteORDept</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $cf_site = $self->TicketObj->CustomFieldValues(1);</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $cf_dept = $self->TicketObj->CustomFieldValues(9);</FONT>

<BR><FONT SIZE=2 FACE="Arial"># Only do it for certain queues.</FONT>

<BR><FONT SIZE=2 FACE="Arial">my @queues = (27,28,7,9,10,31,11,33,32,21,14,16,17,18,34,42,45);</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $queue_id = $self->TicketObj->Queue;</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $val = grep { /^${queue_id}$/ } @queues;</FONT>

<BR><FONT SIZE=2 FACE="Arial">if ($val) {</FONT>

<BR><FONT SIZE=2 FACE="Arial">  if (($cf_site->Count == 0) && ($cf_dept->Count == 0)) { </FONT>

<BR><FONT SIZE=2 FACE="Arial">    my ($id, $msg) = $self->TicketObj->SetStatus("open");</FONT>

<BR><FONT SIZE=2 FACE="Arial">    $self->TicketObj->Comment(Content => "You must set select at least one Site or one Department!");</FONT>

<BR><FONT SIZE=2 FACE="Arial">  }</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>

<BR><FONT SIZE=2 FACE="Arial">return 1;</FONT>

<BR><FONT SIZE=2 FACE="Arial">-----</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">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!  =)</FONT></P>

<P><FONT SIZE=2 FACE="Arial">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.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Enjoy!  Hopefully someone will find these useful!</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">-----</FONT>

<BR><FONT SIZE=2 FACE="Arial">Sean Edge</FONT>

<BR><FONT SIZE=2 FACE="Arial">Consultant</FONT>

<BR><FONT SIZE=2 FACE="Arial">MTV Networks</FONT>
</P>

<pre>


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].
</pre></BODY>
</HTML>