osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now
MySQL Before Insert Trigger for changing task number
I have created the following trigger through phpmyadmin.
DROP TRIGGER IF EXISTS `generate_task_number_from_ticket`;
CREATE TRIGGER `generate_task_number_from_ticket`
BEFORE INSERT ON `ost_task`
FOR EACH ROW
DECLARE ticketnumber,teamsinto varchar(15);
IF NEW.object_id > 0 THEN
SET ticketnumber = (SELECT number FROM ost_ticket WHERE ticket_id = NEW.object_id) ;
SET teamsinto = (SELECT name FROM ost_department WHERE id = NEW.dept_id) ;
SET NEW.number = CONCAT(ticketnumber,'.', teamsinto);
Basically, what im trying to do is to change the task's number (if belongs to a ticket) to ticket's number + task's department name, so user can easily recognize where the task belongs and what was the department.
The problem with this trigger is that if i test it in phpmyadmin (run an insert query), trigger works fine, but If i create a new task from osticket, trigger is not firing and no changes are made.
Definer in trigger, is the same user I use in ost-config.php