Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Slack integration - Ticket updated


I´am working trying to send a notification when user/agent did update a ticket using the "model.updated" signal. But this seems to fire the signal before the ticket edition finish when i do press the "publish" button.

How can i fix this behavior?



  • edited August 2017
    That is exactly when that signal is sent. Immediately before the save action. 

    Problem is, model.updated is sent for EVERY model.. not just tickets. 

     grep -rn model.updated *
    include/class.ticket.php:2868:        Signal::send('model.updated', $this);
    include/class.task.php:1248:        Signal::send('model.updated', $this);
    include/        Signal::connect('model.updated', array($this, 'updateModel'));
    include/class.orm.php:622:            Signal::send('model.updated', $this, $data);

    I suggest using something like:

    Signal::connect ( 'threadentry.created', function (ThreadEntry $entry) {
    // $entry knows what's up. 
    } );

  • I am trying this:

    Signal::connect('threadentry.created', array($this, 'onTicketUpdated'), 'Ticket');

    But not works. Anyway, I'm not clear when it runs.

    Thank you!

  • It does on mine, your implementation is a little different to mine.. possibly why it's not working.

    Just chuck that in your plugin bootstrap, and vardump $entry, then add a message to a ticket or create a ticket etc, and you'll see your dump.
  • Just checked a plugin I wrote, and I use that signal perfectly:

    The bootstrap method receives the signal and then the plugin adds collaborators and sends notifications etc, kinda close to what you're working on. Feel free to fork and change it mate.
  • Awesome. Will be trying it.

  • Hi Grizly!

    Thank you, your code is good for my purposes. I´am trying: 

    inside boostrap:
    Signal::connect ( 'threadentry.created', array($this, 'onTicketUpdated'));

    Then, the function:

    function onTicketUpdated($entry){

    try {
    global $ost;
    $ticket = $this->getTicket ( $entry );

    But i´am having the following error:

    Fatal error
    : Call to undefined method SlackPlugin::getTicket() 

    What am i forgetting?


  • In my method, $this refers to the Mentioner plugin, so getTicket is defined there, couldn't see how to get it from the thread entry while it's being created, but added a function to find it:

    It probably should be an available method for the base class though.
  • FYI: If you're still struggling with this, use my fork:
Sign In or Register to comment.