Event not triggered while setting dynamic field value via API call

English! place to talk about development, programming and coding
Post Reply
soos
Znuny newbie
Posts: 38
Joined: 12 Mar 2014, 11:53
Znuny Version: 3.3.1
Real Name: O

Event not triggered while setting dynamic field value via API call

Post by soos »

I'm currently creating an event module which reacts to the setting of the ITSM due date field. It works fine if I set it through the interface in the "Additional ITSM fields" dialog. But when I set the value via code, it seems the event is not triggered. Do I have to trigger the event separately or something?
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Event not triggered while setting dynamic field value via API call

Post by RStraub »

Hey there,

I took a look into the Ticket.pm, for example if you update a title. This function also triggers an event:

Code: Select all

    $Self->EventHandler(
        Event => 'TicketTitleUpdate',
        Data  => {
            TicketID => $Param{TicketID},
        },
        UserID => $Param{UserID},
    );
So how exactly are you updating your value via code? You might want to look into the perl file that handles the updates, or simply add an event to your code.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
soos
Znuny newbie
Posts: 38
Joined: 12 Mar 2014, 11:53
Znuny Version: 3.3.1
Real Name: O

Re: Event not triggered while setting dynamic field value via API call

Post by soos »

Code: Select all

       
          my $Success = $Self->{DynamicFieldValueObject}->ValueSet(
           FieldID => 10,
           ObjectID => $Param{Data}->{TicketID},
           Value => [
           {
               ValueDateTime => $timestamp,
           },
           ],
           UserID => 1,
         );
This is how I'm updating the dynamic field.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Event not triggered while setting dynamic field value via API call

Post by RStraub »

If you look into the code:

https://github.com/OTRS/otrs/blob/rel-4 ... lue.pm#L82

There is nothing about raising an event. You might have to raise an event via the EventHandler.

Try naming your event "TicketDynamicFieldUpdate_NameOfYourField".
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
soos
Znuny newbie
Posts: 38
Joined: 12 Mar 2014, 11:53
Znuny Version: 3.3.1
Real Name: O

Re: Event not triggered while setting dynamic field value via API call

Post by soos »

Fantastic! Thanks! Have a great day!
Post Reply