CreateChildTicket: Difference between revisions
m (2 revisions imported) |
(No difference)
|
Latest revision as of 15:03, 6 April 2016
Add this to /opt/rt3/local/html/Callbacks/SA/Ticket/Display.html/BeforeShowHistory and it will create ugly button to create a child ticke in another queue
<FORM ACTION="<% $RT::WebPath %>/Ticket/Create.html" NAME="CreateTicketInQueue"> <input type="submit" value="Create child request in"> <& /Elements/SelectQueue, Name => 'Queue', %ARGS, ShowNullOption => 0, ShowAllQueues => 0 &> <input type="hidden" name="new-MemberOf" value="<%$Ticket->Id%>"> <input type="hidden" name="Subject" value="Child of: <%$Ticket->Subject%>"> </FORM> <%INIT> </%INIT> <%ARGS> $Ticket => undef $Verbose => 0 $Default => 0 </%ARGS>
I improved this a bit. Put into /usr/local/share/request-tracker3.6/html/Callbacks/LOCAL/Ticket/Elements/ShowTransaction
% if ($Transaction->Type =~ /^(Create|Correspond|Comment)$/) { <form action="<% $RT::WebPath %>/Ticket/Create.html" name="CreateTicketInQueue"> <script type="text/javascript"> function setrelationship (select) { var wert = select.options[select.options.selectedIndex].value; select.form.elements["new-MemberOf"].value = ""; select.form.elements["new-DependsOn"].value = ""; select.form.elements["new-RefersTo"].value = ""; select.form.elements["MemberOf-new"].value = ""; select.form.elements["DependsOn-new"].value = ""; select.form.elements["RefersTo-new"].value = ""; select.form.elements[wert].value = "<%$Ticket->Id%>"; } </script> <input type="hidden" name="new-MemberOf" value=""> <input type="hidden" name="new-DependsOn" value=""> <input type="hidden" name="new-RefersTo" value=""> <input type="hidden" name="MemberOf-new" value=""> <input type="hidden" name="DependsOn-new" value="<%$Ticket->Id%>"> <input type="hidden" name="RefersTo-new" value=""> <p align="right"> Create new <select name="how-depends" onchange="setrelationship(this)"> <option value="new-DependsOn">Parent (dependent)</option> <option selected value="DependsOn-new">Child (dependent)</option> <option value="MemberOf-new">Parent (independent)</option> <option value="new-MemberOf">Child (independent)</option> <option value="new-RefersTo">Refers to</option> <option value="RefersTo-new">Refered to by</option> </select> <input type="submit" value="Ticket"> in <& /Elements/SelectQueue, Name => 'Queue', %ARGS, ShowNullOption => 0, ShowAllQueues => 0 &> </p> </form> % } <%ARGS> $Ticket => undef $Transaction => undef $Verbose => 0 $Default => 0 </%ARGS>
This doesn't work and results in the following:<br /><br />
Error during compilation of /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction:<br /> Global symbol "%if" requires explicit package name at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 197.<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 197, near "% if ("<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 205, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 206, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 207, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 208, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 209, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 210, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 212, near "elements["<br /> syntax error at /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction line 214, near "}<br /> </script>"<br /> /usr/local/rt3/local/html/Ticket/Elements/ShowTransaction has too many errors.<br /> <br /><br /> ...<br /> 193: }<br /> 194: }<br /> 195: }<br /> 196: <br /> 197: % if ($Transaction->Type =~ /^(Create|Correspond|Comment)$/) {<br /> 198: <br /> 199: <form action="<% $RT::WebPath %>/Ticket/Create.html"<br /> 200: name="CreateTicketInQueue"><br /> 201: <br /> 202: <script type="text/javascript"><br /> 203: function setrelationship (select) {<br /> 204: var wert = select.options[select.options.selectedIndex].value;<br /> 205: select.form.elements["new-MemberOf"].value = "";<br /> 206: select.form.elements["new-DependsOn"].value = "";<br /> 207: select.form.elements["new-RefersTo"].value = "";<br /> 208: select.form.elements["MemberOf-new"].value = "";<br /> 209: select.form.elements["DependsOn-new"].value = "";<br /> 210: select.form.elements["RefersTo-new"].value = "";<br /> 211: <br /> 212: select.form.elementswert.value = "<%$Ticket->Id%>";<br /> 213: }<br /> 214: </script><br /> 215: <br /> 216: <input type="hidden" name="new-MemberOf" value=""><br /> 217: <input type="hidden" name="new-DependsOn" value=""><br /> 218: <input type="hidden" name="new-RefersTo" value=""><br /><br />
... <br /> /usr/lib/perl5/vendor_perl/5.8.7/HTML/Mason/Interp.pm:454<br /> /usr/lib/perl5/vendor_perl/5.8.7/HTML/Mason/Request.pm:1088<br /> /usr/lib/perl5/vendor_perl/5.8.7/HTML/Mason/Request.pm:1002<br /> /usr/lib/perl5/vendor_perl/5.8.7/HTML/Mason/Request.pm:1197<br /> /usr/local/rt3/share/html/Ticket/Elements/ShowHistory:104<br /> /usr/local/rt3/share/html/Ticket/Display.html:65<br /> /usr/local/rt3/share/html/autohandler:291<br />
The above works for me, with Minor changes. (RT 3.6.6)
1) Copied /opt/rt3/share/html/Ticket/Elements/ShowTransaction to /opt/rt3/local/html/Ticket/Elements/ShowTransaction.
2) Pasted the code in after <%/INIT>
3) Changed the <%ARGS>...<%/ARGS> Section to this:
<%ARGS> $Verbose => 0 $Default => 0 </%ARGS>
4) Restart Web Server
5) Now after each comment or reply we get a small form that gives the option of Creating a Child Ticket of the current ticket<br />
Quick and dirty callback that gives you a 'Split' function for splitting one ticket into another (keeping the subject, requestor etc). I put the following in html/Callbacks/WHATEVER/Ticket/Elements/Tabs/Defaults
<%init> if ($Ticket) { $actions->{'split-ticket'} = { title => loc('Split'), path => 'Ticket/Create.html?Queue=1&Subject='.$Ticket->Subject.'&new-MemberOf='.$Ticket->Id.'&Requestors='.$Ticket->RequestorAddresses }; } </%init> <%args> $Ticket =>undef $tabs => undef $actions => undef </%args>
That's it. Remember to restart webserver.
^^^ Doesn't seem to work as written?
Here's another improved version for RT 3.6.6. The new ticket will be opened with most fields already populated.
1) Copy /opt/rt3/share/html/Ticket/Elements/ShowTransaction to /opt/rt3/local/html/Ticket/Elements/ShowTransaction.
2) Add this code after the </%INIT> tag and restart the your web server. You may want to change the "Approval" queue name to suit your approval queue name.
% if ( $Transaction->Type =~ /^(Create|Correspond|Comment)$/ && $Ticket->QueueObj->Name !~ /^(Approval)$/) { <form action="<% $RT::WebPath %>/Ticket/Create.html" name="CreateTicketInQueue"> <script type="text/javascript"> function setrelationship (select) { var wert = select.options[select.options.selectedIndex].value; select.form.elements["new-MemberOf"].value = ""; select.form.elements["new-DependsOn"].value = ""; select.form.elements["new-RefersTo"].value = ""; select.form.elements["MemberOf-new"].value = ""; select.form.elements["DependsOn-new"].value = ""; select.form.elements["RefersTo-new"].value = ""; select.form.elements[wert].value = "<%$Ticket->Id%>"; if (wert == "DependsOn-new") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Dep. Child of <%$Ticket->Id%>)"; } else if (wert == "new-MemberOf") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Child of <%$Ticket->Id%>)"; } else if (wert == "new-DependsOn") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Depends on <%$Ticket->Id%>)"; } else if (wert == "MemberOf-new") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Parent of <%$Ticket->Id%>)"; } else if (wert == "new-RefersTo") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Refers to <%$Ticket->Id%>)"; } else if (wert == "RefersTo-new") { select.form.elements["Subject"].value = "<%$Ticket->Subject%> (Refered to by <%$Ticket->Id%>)"; } else { select.form.elements["Subject"].value = ""; } } </script> <input type="hidden" name="new-MemberOf" value=""> <input type="hidden" name="MemberOf-new" value=""> <input type="hidden" name="new-DependsOn" value=""> <input type="hidden" name="DependsOn-new" value="<%$Ticket->Id%>"> <input type="hidden" name="new-RefersTo" value=""> <input type="hidden" name="RefersTo-new" value=""> <input type="hidden" name="id" value="<%$desc%>"> <input type="hidden" name="CloneTicket" value="<%$Ticket->Id%>"> <input type="hidden" name="Subject" value="<%$Ticket->Subject%> (Dep. Child of <%$Ticket->Id%>)"> <input type="hidden" name="QuoteTransaction" value="<%$Transaction->Id%>"> <input type="hidden" name="Status" value="new"> <input type="hidden" name="Requestors" value=""> <input type="hidden" name="Cc" value="<%$Ticket->Requestors->MemberEmailAddressesAsString%>,<%$Ticket->Cc->MemberEmailAddressesAsString%>"> <p align="right"> Create new <select name="how-depends" onchange="setrelationship(this)"> <option value="DependsOn-new" selected>Child (dependent)</option> <option value="new-MemberOf">Child (independent)</option> <option value="new-DependsOn">Parent (dependent)</option> <option value="MemberOf-new">Parent (independent)</option> <option value="new-RefersTo">Refers to</option> <option value="RefersTo-new">Refered to by</option> </select> <input type="submit" value="Ticket"> in <& /Elements/SelectQueue, Name => 'Queue', %ARGS, ShowNullOption => 0, ShowAllQueues => 0 &> </p> </form> % }