[Rt-devel] Button that Creates an Approval Ticket
Conrad Gratz
gratz.1 at osu.edu
Mon Mar 9 14:08:33 EDT 2009
I'm newbie at RT and could use some help. I have created a button for
adding an approval to an existing ticket, but had to resort to some less
than desirable coding practices (hacks) to make it work. There must be a
better way to to do this. If anyone has a better plan please let me
know. I'm using RT3.8.2 on linux.
Thanks,
Conrad
Here is what I have written:
#### This code is at the end of a local copy of ShowTransaction, this
abuses the 'Comment' action.
%# Approval button from wiki.bestpractical.com/view/CreateChildTicket -
CPG 2/09
% if ( $Transaction->Type =~ /^(Create)$/
% && $ENV{'REQUEST_URI'} !~ /(\/Approvals\/)/
% && $Ticket->QueueObj->Name =~ /^(MyQueue)$/) {
<form action="<% $RT::WebPath %>/Ticket/Update.html" name="TicketUpdate">
<input type="hidden" name="Action" value="Comment">
<input type="hidden" name="DefaultStatus" value="">
<input type="hidden" name="UpdateType" value="private">
<input type="hidden" name="id" value="<%$Ticket->Id%>">
<input type="hidden" name="new-RefersTo" value="">
<input type="hidden" name="RefersTo-new" value="">
<input type="hidden" name="QuoteTransaction" value="<%$Transaction->Id%>">
<input type="hidden" name="Status" value="">
<input type="hidden" name="UpdateSubject" value="Approval Requested">
<input type="hidden" name="UpdateContent" value="Approval Requested">
<p align="right">
<input type="submit" name="SubmitTicket" value="Create Approval Ticket">
</p>
</form>
% }
##### Custom Condition for MyQueue scrip. This abuses 'Subject' to sort
out approval requests. Action is 'Create Tickets'.
my $result = 0;
if ($self->TransactionObj->Type eq "Comment"
&& $self->TransactionObj->Data =~ /(Approval Requested)$/) {
$result = 1;
}
return($result);
#### Template for the above. This is from the bestpractical wiki and
works fine.
===Create-Ticket: myapproval
Subject: Request Approval for {$Tickets{'TOP'}->Subject}
Depended-On-By: TOP
Queue: Ops_Approvals
Type: approval
Owner: gratz
AdminCC: {
my $group_name = 'Ops_Approvers';
my $groups = RT::Groups->new( $RT::SystemUser );
$groups->LimitToUserDefinedGroups();
$groups->Limit(
'FIELD' => 'Name',
'OPERATOR' => '=',
'VALUE' => $group_name );
$groups->First->Id;
}
Content: A ticket needs your attention. Please approve it so any work
requested may be completed.
ENDOFCONTENT
More information about the Rt-devel
mailing list