[rt-users] CannedReplies on Create

Stephen Turner sturner at MIT.EDU
Fri Dec 14 15:44:31 EST 2007


At Friday 12/14/2007 03:15 PM, Drew Barnes wrote:
>The CannedReplies callback has done wonders for our staff with regards
>to frequent requests, whether it be for temporary admin rights to
>install software updates or when a better computer comes available,
>allowing us to notify possible recipients.
>
>The question that has been posed to me (and I have bald spots from
>trying this out) is if the CannedReplies can be instituted on ticket
>creation, rather than on update.
>
>Any thoughts or ideas to kick me in the right direction?
>
>Drew

Drew,

I'm assuming you're wanting to use this from the ticket Create page. 
It won't work as-is, but it could be easily adapted.  The main 
difference is that on the Create page, there is no ticket yet, so the 
references in the callbacks to ticket obj and ticket id would fail. 
Another difference is that Create.html has no callback before the message box.

To adapt (I haven't tested this!): you can either add a callback 
statement into Create.html  and put the following code in the 
callback file, or put this code directly into Create.html:

<tr>
<td>Canned reply:</td>
<td><& /Admin/Elements/SelectTemplate, Name => "Canned-Template", 
Queue => $QueueObj->id &>
<input type="submit" name="select_template" value="Go"></td>
</tr>

You'd also have to modify the second callback 
(Callbacks/<whatever>/Elements/MessageBox/Default) to account for the 
possibility of no ticket object being present. Also, in templates to 
be used in Create.html, you wouldn't be able to include any ticket fields:

%#
%# Allows use of templates as 'canned replies' in update screen.
%# Looks up the template specified, parses it and displays the parsed
%# template content.
%#
% if ($content) {
<% $content %>
% }
<%init>
my $template;
my $trans = new RT::Transaction( $session{'CurrentUser'} );
my $ticket = new RT::Ticket( $session{'CurrentUser'} );
my $content = "";

if ( $ARGS{'select_template'} ) {
     my $template_id = $ARGS{'Canned-Template'};
     if ($template_id) {
         $template = RT::Template->new($session{'CurrentUser'});
         $template->Load($template_id);
         if ($template->id) {
             $TicketObj = LoadTicket($ARGS{'id'}) if ($ARGS{'id'} && 
$ARGS{'id'} ne 'new');
             $template->Parse(TicketObj => $TicketObj,
                              TransactionObj => $trans);
             $content = $template->MIMEObj->stringify;
         }
     }

}
</%init>







More information about the rt-users mailing list