Home > osTicket > How to Insert Ticket Number into Premade Reply Answer in osTicket v1.6 RC5

How to Insert Ticket Number into Premade Reply Answer in osTicket v1.6 RC5

Have you ever wanted to include the ticket number into the Premade Reply answer in osTicket System, especially when staff reply to a ticket by using the certain premade reply? Now you can do it by modifying only two lines of code in \include\class.ticket.php file. Assuming you use the %ticket that representing the 6 digits of ticketID. Well, here is the solution I have successfully created to implement it.

  1. Open your \include\class.ticket.php file, and find this code:

    743
    
                    ',response='.db_input(Format::striptags($response)).

    then replace with this following code:

    743
    
                    ',response='.db_input(Format::striptags(str_replace('%ticket', $this->getExtId(), $response))).

    Find again this code:

    783
    
                    $body = str_replace("%signature",$signature,$body);

    then after that please insert this following code:

    784
    
                    $body = str_replace("%ticket",$this->getExtId(),$body);
  2. Go to Admin Panel -> Knowledge Base -> Premade Replies, then click on the only item with title “What is osTicket (sample)?”, then on the next page, change this following value:

    osTicket is a support ticket system

    become:

    osTicket is a support ticket system 
    This ticket number: %ticket
  3. Try to answer one of the tikcets, for example you already have this ticket number 543652, then view this ticket from staff panel, select that premade reply above, then click on Post Reply button to send the reply to that ticket, then that ticket number should be change in that reply become:

    osTicket is a support ticket system 
    This ticket number: 543652

Enjoy it, everyone!

  • Share/Bookmark
184 views Print This Post Print This Post

  1. bhoward
    March 4th, 2010 at 11:45 | #1

    Thanks for the code! But I was wondering: how can I add more variables to the code?

    I’d like to put ticket number (%ticket), customer price (%price), and maybe a few more variables in there. I’ve been trying to figure it out all day, but I don’t know what to do. =\

    Please help if you can! (PS: I’m also a member of osTicket Forums; I have the same username there.)

  2. March 4th, 2010 at 13:47 | #2

    You might add your own variables to the replaceTemplateVars function that located in /include/class.ticket.php file. Besides that, you have to learn about the related functions and or files; depending on your own need.

  3. bhoward
    March 4th, 2010 at 14:21 | #3

    Well, I already did that earlier. I think I added variables in all the necessary places, including:

    $search = array(‘/%ticket/’,'/%price/’)
    $replace = array($this->getExtId(), $this->getPrice(),

    After that, I just copied/pasted your code TWICE (for “%ticket” and “%price”), like this:

    $body = str_replace(“%price”,$this->getPrice(),$body);
    $body = str_replace(“%ticket”,$this->getExtId(),$body);

    I did the same thing for the second line of code you gave. But I’m still getting no results. =(

  1. No trackbacks yet.