If you want to customize the ticket number in your osTicket System, then this modification is for you. As we know, the ticketID field in ost_ticket table has the field type as int(11). It means that this field can only contains of the numerical data. Sometimes you want to change that original ticket number from which contains of the six digits numerical data become something which contains of the alpha-numeric characters. For example, you want to add the Custom prefix which in this case contains of letters, then you have to alter that field type, for instance, become varchar(12).
- Alter your ost_ticket table by changing the type of ticketID field, from int(11) become varchar(12). Adjust the value: 12 with your requirement.
-
Open your \include\class.misc.php file, and find this code:
30
return mt_rand($start,$end);
then replace with:
30
return "Custom".mt_rand($start,$end);
-
Open your login.php file, and find this code:
44 45
//See if we can fetch local ticket id associated with the ID given if(!$errors && is_numeric($ticketID) && Validator::is_email($email) && ($tid=Ticket::getIdByExtId($ticketID))) {
then replace with this following code:
44 45
//See if we can fetch local ticket id associated with the ID given if(!$errors && Validator::is_email($email) && ($tid=Ticket::getIdByExtId($ticketID))) {
-
Open your \include\staff\tickets.inc.php file, and find this code:
136
if(is_numeric($searchTerm)){
then replace with this following code:
136
if($searchTerm){
-
Open your \include\ajax.tickets.php file, and find this code:
49
if(is_numeric($input)) {
then replace with this following code:
49
if($input) {
Find again this code:
71
if(!$params['tid'] or !is_numeric($params['tid']))
then replace with this following code:
71
if(!$params['tid'])
Find again this code:
104
if(!$params['id'] or !is_numeric($params['id']))
then replace with this following code:
104
if(!$params['id'])
-
Open your tickets.php file, and find this code:
if(($id=$_REQUEST['id']?$_REQUEST['id']:$_POST['ticket_id']) && is_numeric($id)) { //id given fetch the ticket info and check perm. $ticket= new Ticket(Ticket::getIdByExtId((int)$id));
then replace with this following code:
if(($id=$_REQUEST['id']?$_REQUEST['id']:$_POST['ticket_id']) && $id) { //id given fetch the ticket info and check perm. $ticket= new Ticket(Ticket::getIdByExtId($id));
-
Open your /include/class.ticket.php file, and find this code:
1226 1227
$extId=$id; //To make things really easy we are going to use autoincrement ticket_id. db_query('UPDATE '.TICKET_TABLE.' SET ticketID='.db_input($extId).' WHERE ticket_id='.$id);
then replace with this following code:
1226 1227
$extId=$id; //To make things really easy we are going to use autoincrement ticket_id. db_query('UPDATE '.TICKET_TABLE.' SET ticketID="Custom'.db_input($extId).'" WHERE ticket_id='.$id);
In this example, you want to add the Custom prefix into the ticket number.

hey my friends,
nice article, but something missing in your article:
in include\class.ticket.php
Line 1331 and 1332 search for:
replace with:
@Malte Glöckner
Thanks for the correction. I have added that missing step.
Cheers!
Great article and easy to follow with thanks.
For those that use piping for adding email replies to ticket you will have to edit the pipe.php file as follows:
File: installdir/includes/api/pipe.php
Lines 94 & 95 – original
Replace to:
At least that’s what I did and my pipe is now working a treat. If you dont change this piping doesn’t work and it just creates a new ticket when someone replies to an email response.
@Clive Hawkins
Thanks for the feedback, Clive. I appreciate it.
it is not letting me change the ost_ticket ticketid field. It keeps saying this:
SQL query:
ALTER TABLE `ost_ticket` CHANGE `ticketID` `ticketID` VARCHAR( 12 ) UNSIGNED NOT NULL DEFAULT ’0′
MySQL said: Documentation
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘UNSIGNED NOT NULL DEFAULT ’0” at line 1
Your SQL query should be like this:
Thanks Masino! Appreciate it! Your tutorials are some of the best! Better than on the osticket forum.
Have a question. Do you have a tutorial on how to make staff signatures html?
I tried that string from above and received this error:
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’0′’ at line 1
Please re-copy that SQL above and execute again. I have just fixed the single quote that encloses the value of zero.
thanks it worked. Took a second to figure out where to add my customized part to it, but I got that.