Need a little help with Sequential IDs
Moderator: mkoch227
Need a little help with Sequential IDs
Script URL:
Version of script: 2.4.2
What terms did you try when SEARCHING for a solution: sequential
Write your message below:
Howdy Klemen! Got a new client who just bought Hesk and will be using it to manage their purchasing department. Everything is an easy fit except for the Ticket IDs. We'd like to switch out all the viewable areas that call for the Ticket ID to show the Sequential ID instead, using the Sequential ID's as their Purchase Order numbers.
1) What code for the field would I call to do this?
2) Can I also replace the Ticket IDs with the Sequential IDs in the email subjects & reply text? Or will this break the reply by email routine? If so, in what areas can I safely replace it?
Thanks for any help you can provide!
-Lisa
Version of script: 2.4.2
What terms did you try when SEARCHING for a solution: sequential
Write your message below:
Howdy Klemen! Got a new client who just bought Hesk and will be using it to manage their purchasing department. Everything is an easy fit except for the Ticket IDs. We'd like to switch out all the viewable areas that call for the Ticket ID to show the Sequential ID instead, using the Sequential ID's as their Purchase Order numbers.
1) What code for the field would I call to do this?
2) Can I also replace the Ticket IDs with the Sequential IDs in the email subjects & reply text? Or will this break the reply by email routine? If so, in what areas can I safely replace it?
Thanks for any help you can provide!
-Lisa
- Lisa
Re: Need a little help with Sequential IDs
The sequential ID is stored in the "id" field as opposed to the "trackid" where the randomly-generated one is.
However, I wouldn't recommend switching the fields. Even if you don't mind the privacy issue with easily guessable IDs, there are potentially others problems that could occur and would require a lot of modifying/maintenance.
The better approach would be to just modify the function that generates the tracking IDs so that the generated IDs fit your needs. Namely, the hesk_createID function located in inc/common.inc.php
This way instead of modifying HESK in a lot of places and potentially generating many problems, you just generate the ID the way you want it.
The way I would do it:
1. create a simple new table that would hold the next ticket ID. For example "hesk_next_id" with a single "next_id" INT UNSIGNED column.
2. manually insert a row into the hesk_next_id table with the first purchase order number, for example "1" or "10000" or whatever.
3. modify the hesk_createID function to:
- get next ticket value from the hesk_next_id table (for example 10001)
- update the value in hesk_next_id table by 1
- return the value of the hesk_next_id table as the value hesk_createID function returns (you can even manipulate it first, for example by adding year before the value - for example "2013-10001"
However, I wouldn't recommend switching the fields. Even if you don't mind the privacy issue with easily guessable IDs, there are potentially others problems that could occur and would require a lot of modifying/maintenance.
The better approach would be to just modify the function that generates the tracking IDs so that the generated IDs fit your needs. Namely, the hesk_createID function located in inc/common.inc.php
This way instead of modifying HESK in a lot of places and potentially generating many problems, you just generate the ID the way you want it.
The way I would do it:
1. create a simple new table that would hold the next ticket ID. For example "hesk_next_id" with a single "next_id" INT UNSIGNED column.
2. manually insert a row into the hesk_next_id table with the first purchase order number, for example "1" or "10000" or whatever.
3. modify the hesk_createID function to:
- get next ticket value from the hesk_next_id table (for example 10001)
- update the value in hesk_next_id table by 1
- return the value of the hesk_next_id table as the value hesk_createID function returns (you can even manipulate it first, for example by adding year before the value - for example "2013-10001"
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Need a little help with Sequential IDs
Thanks for your reply Klemen. I probably should have been more clear. I'm really not interested in obliterating the tracking ID - I was just wondering where I could replace it in viewable fields without having an issue. If I still leave the tracking IDs intact, and doing what it is supposed to do, I'd like to be able to call up the Sequential IDs where ever needed as well. And maybe I'll need to hire a programmer to help me do it the way you are describing now, but I'd like to try doing it using the sequential IDs first.
So if I don't switch the fields, but still want to call up the sequentail ID, how would I do so?
Thanks for your help!
-Lisa
So if I don't switch the fields, but still want to call up the sequentail ID, how would I do so?
Thanks for your help!
-Lisa
- Lisa
Re: Need a little help with Sequential IDs
Where there is "trackid" from the table printed (for example $ticket["trackid"]) you will need to change that to "id" (for example $ticket["id"]). You will need to do quite some changes throughout the script though.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Need a little help with Sequential IDs
Thanks klemen! Would I also use the same to call it in the emails?
- Lisa
Re: Need a little help with Sequential IDs
To use it in emails, you will need to edit functions hesk_getEmailMessage and hesk_getEmailSubject in the inc/email_functions.inc.php
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Need a little help with Sequential IDs
Okay, let me guess based on my emerging but limited knowledge of php.
On the two functions you mentioned, I added this to the /* Replace all special tags */
And then called it by adding %%TRACK_MRF%% to the emails. But the field came up blank.
I feel I am so close! Was there anything else I needed to edit?
Thanks again!
On the two functions you mentioned, I added this to the /* Replace all special tags */
Code: Select all
$msg = str_replace('%%TRACK_MRF%%', $ticket['id'] ,$msg);
I feel I am so close! Was there anything else I needed to edit?
Thanks again!
- Lisa
Re: Need a little help with Sequential IDs
Ah, it *is* working! I was testing it on the "New Ticket" emails - but it is working on all the others. Would you be willing to share how can I get it to show up on the "New Ticket" email notifications (if it's not too complicated)?
Thank you!
Thank you!

- Lisa
Re: Need a little help with Sequential IDs
When a new ticket is created, the ID is not available yet, because it is assigned by MySQL when inserted.
So you will need to pull out the last assigned ID: in inc/posting_functions.inc.php just below try
So you will need to pull out the last assigned ID: in inc/posting_functions.inc.php just below
Code: Select all
$info = array(
Code: Select all
'id' => hesk_dbInsertID(),
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools