You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2024-07-17 01:29:36

jetriixsm
Member
Registered: 2024-05-25
Posts: 14

Hooks Problem

Hello, im working with tickets hooks and one of them is when the ticket is updated by a followup but i realice that the hook only is activated when is the first followup of the ticket because if i add another one the hook is not activated, someone knows why this happend or how to fix it or another way to do this?

//setup.php
function plugin_init_whatsappapi(){

    global $PLUGIN_HOOKS,$CFG_GLPI;
    $PLUGIN_HOOKS['csrf_compliant']['whatsappapi'] = true;

    $PLUGIN_HOOKS['item_add']['whatsappapi'] = ['Ticket'  => 'Whatsappapi_ticket_createitem_called'];
    $PLUGIN_HOOKS['item_update']['whatsappapi'] = ['Ticket'  => 'Whatsappapi_ticket_updateitem_called'];
}

//function from hook.php

function Whatsappapi_ticket_updateitem_called(CommonDBTM $item) {
    global $DB;
    $tipo = $item::getType();
    if ($item::getType() === Ticket::getType()) {
        $fields = $item->fields;
        $users = $item->users[1][0];
        $clienteId = $users['users_id'];
        $Ticket_Id = $fields['id'];
        /*
        $result = $DB -> request(['FIELDS' => ['glpi_itilfollowups' => ['id','content']], 'FROM' => 'glpi_itilfollowups','WHERE' =>['itemtype' => ['Ticket'],['AND' => ['is_private'=>'0','items_id' => $Ticket_Id,'users_id' => $clienteId,'requesttypes_id' => '1']]],'ORDER BY' => 'date_creation DESC','LIMIT' => '1']);
        foreach ($result as $mensajes) {
            $followupId = $mensajes['id'];
            $mensaje = $mensajes['content'];
        }
        */
        write($clienteId);
    }
}

Offline

#2 2024-07-18 13:53:28

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Hooks Problem

Why not listen to the creation of followups instead?


GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.

Offline

#3 2024-07-18 17:21:35

jetriixsm
Member
Registered: 2024-05-25
Posts: 14

Re: Hooks Problem

what? that specific hook exist? , where i can find the documentation because in the documentation page i didnt  found it,btw thanks u for let me know that

Offline

#4 2024-07-18 20:05:33

jetriixsm
Member
Registered: 2024-05-25
Posts: 14

Re: Hooks Problem

nvm i found how to do it thanks

Offline

Board footer

Powered by FluxBB