Thanks for the tip @Micke1101
I tried a lot around yesterday but could not get it to work.
I put my code right after the
$ticket = $thread->getObject();
since we only have tickets right now. I saw something confusing though: It threw a php error saying getObjectType() was run on null value. I took a look at the thread_entry table and the pid column only has rows with value 0. Is that even correct? Or should pid be equal to the ticket the thread belongs to?
I am also confused since in the onMessage function, my code only works if I put it after the initial $this stuff. If I put it at the end of the function, it doesn't work at all.
My code also works perfectly under the onAssign and onNewTicket functions, for BOTH frontend and mail tickets..
I am sorry for the many questions but I hope you can help me.