Page 1 of 1
Need a little help with Sequential IDs
Posted: Sat Mar 30, 2013 3:27 pm
by Lisaweb
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
Re: Need a little help with Sequential IDs
Posted: Mon Apr 01, 2013 9:03 am
by Klemen
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"
Re: Need a little help with Sequential IDs
Posted: Mon Apr 01, 2013 1:17 pm
by Lisaweb
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
Re: Need a little help with Sequential IDs
Posted: Mon Apr 01, 2013 5:07 pm
by Klemen
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.
Re: Need a little help with Sequential IDs
Posted: Mon Apr 01, 2013 9:40 pm
by Lisaweb
Thanks klemen! Would I also use the same to call it in the emails?
Re: Need a little help with Sequential IDs
Posted: Tue Apr 02, 2013 3:19 pm
by Klemen
To use it in emails, you will need to edit functions hesk_getEmailMessage and hesk_getEmailSubject in the inc/email_functions.inc.php
Re: Need a little help with Sequential IDs
Posted: Tue Apr 02, 2013 11:16 pm
by Lisaweb
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 */
Code: Select all
$msg = str_replace('%%TRACK_MRF%%', $ticket['id'] ,$msg);
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!
Re: Need a little help with Sequential IDs
Posted: Tue Apr 02, 2013 11:51 pm
by Lisaweb
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!

Re: Need a little help with Sequential IDs
Posted: Wed Apr 03, 2013 3:37 pm
by Klemen
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
Re: Need a little help with Sequential IDs
Posted: Wed Apr 03, 2013 11:19 pm
by Lisaweb
Yay! That worked!!!

Thank you sooo much Klemen!