[otrs] How to get the value of a dynamic field in an event module

2,533 views
Skip to first unread message

Bernard Chambon

unread,
Jun 14, 2012, 6:12:53 AM6/14/12
to ot...@otrs.org

Hello,

I want to run an action , using event, according to the value of a dynamic field 
( dynamic field is a check box, let say "IsCompanyTicket")

The current situation :
 dynamic field created and associated to Customer::Frontend 
 new ConfigItem added in Kernel/Config/Files/Ticket.xml
 Event module created in Kernel/System/Ticket/Event/

 In that module, I can see (print) the dynamic Field name DynamicField_IsCompanyTicket, th'at's ok
 but I DON'T know how to get the value
 I meant that something like :
  my $df_value = $Ticket{DynamicField_IsCompanyTicket}; 

 doesn't work, I got no value
 I have tried with checkbox but also textfield.

I don't kown where to look for in documentation ?

Best regards.

---------------
Bernard CHAMBON
IN2P3 / CNRS
04 72 69 42 18

David Heidt

unread,
Jun 15, 2012, 9:42:49 AM6/15/12
to User questions and discussions about OTRS.
Hello Bernard,

the support of dynamic field Values in the ticket object seems to be completely missing, I opened a bug a couple of days ago, I think your issue is related to mine:

http://bugs.otrs.org/show_bug.cgi?id=8551

Cheers,

David

Am 14.06.12 12:12, schrieb Bernard Chambon:
---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

Martin Gruner

unread,
Jun 15, 2012, 9:58:36 AM6/15/12
to User questions and discussions about OTRS.
Hi Bernard,

just use TicketGet(...., DynamicFields => 1); and you will get all fields on the result hash.

Regards, mg


Am 14.06.12 12:12, schrieb Bernard Chambon:

Hello,

---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

-- 
Martin Gruner
Senior Developer R&D

OTRS AG
Europaring 4
94315 Straubing

T: +49 (0)6172 681988 0
F: +49 (0)9421 56818 18
I:  www.otrs.com/

Geschäftssitz: Bad Homburg, Amtsgericht: Bad Homburg, HRB 10751, USt-Nr.: DE256610065
Aufsichtsratsvorsitzender: Burchard Steinbild, Vorstand: André Mindermann (Vorsitzender), Christopher Kuhn

Verbinden wir uns! OTRS 3.1 schafft einfachere Integration mit Drittapplikationen – Für Frühbucher zum Vorzugspreis: http://www.otrs.com/index.php?id=2361&L=1


Bernard Chambon

unread,
Jun 15, 2012, 12:23:54 PM6/15/12
to User questions and discussions about OTRS.
Hi,

Le 15 juin 2012 à 15:58, Martin Gruner a écrit :

Hi Bernard,

just use TicketGet(...., DynamicFields => 1); and you will get all fields on the result hash.

Regards, mg

In fact I have made a call with DynamicFields => 1
but the problem is that I get the name of the field but not the value

small piece of code :
   
      my %Ticket = $Self->{TicketObject}->TicketGet(
          TicketID => $Param{TicketID},
          UserID   => 1,
          DynamicFields => 1, # To get DynamicFields in Ticket map
      );
      return 1 if !%Ticket;
       
     while( my ($k,$v) = each(%Ticket) ) {
       $Self->{LogObject}->Log( Priority => 'info', Message => "key=$k     value=$v"  );
     }
    $Self->{LogObject}->Log( Priority => 'info', Message => "End of my own module" );

gives :

[Fri Jun 15 17:48:19 2012][Info][Kernel::System::Ticket::Event::EventModuleIsCompanyTicket::Run] key=CreateTimeUnix     value=1339775299
[Fri Jun 15 17:48:19 2012][Info][Kernel::System::Ticket::Event::EventModuleIsCompanyTicket::Run] key=SLAID     value=
[Fri Jun 15 17:48:19 2012][Info][Kernel::System::Ticket::Event::EventModuleIsCompanyTicket::Run] key=CustomerUserID     value=bchambonascustomer
[Fri Jun 15 17:48:19 2012][Info][Kernel::System::Ticket::Event::EventModuleIsCompanyTicket::Run] key=DynamicField_IsCompanyTicket     value=
[Fri Jun 15 17:48:19 2012][Info][Kernel::System::Ticket::Event::EventModuleIsCompanyTicket::Run] End of my own module



I also have other problem with events
I can fire an event with 'TicketCreate' (as in my previous example)
but I CAN'T fire anything when moving Ticket between queue. I have tried several EventName (see below), without result

    <ConfigItem Name="Ticket::EventModulePost###EventModuleIsCompanyTicket" Required="0" Valid="1">
        <Description Translatable="1">To set a ticket as private ...</Description>
        <Group>Ticket</Group>
        <SubGroup>Core::Ticket</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::System::Ticket::Event::EventModuleIsCompanyTicket</Item>
                    <!-- Event fired with TicketCreate, but can't get Value from DynamicField --> 
 <!--               <Item Key="Event">TicketCreate</Item>  -->

                  <!-- Can't fire an event on TicketQueueUpdate , an Event Name problem or something else ? --> 
                 <Item Key="Event">TicketQueueUpdate|TicketMoveTicket|MoveTicket</Item>  
                 <Item Key="new">open</Item>
            </Hash>
        </Setting>
    </ConfigItem>


however , with notification (sending email for ex) 'TicketQueueUpdate' seems to work

hoping better for next week...
Best regards

Michiel Beijen

unread,
Jun 16, 2012, 2:46:16 PM6/16/12
to User questions and discussions about OTRS.
Hi Bernard,

Typically you dump the contents of data structures with a module like Data::Dumper.

So if you'd take the file bin/otrs.GetTicketThread.pl which is on your OTRS system, this utility prints out a ticket to the screen.
If you would open this file in a text editor, set DynamicFields to '1' and then add, at the end of the file, these two lines:

 use Data::Dumper;
 print Dumper (\%Ticket);

and then run bin/otrs.GetTicketThread.pl [TicketID] on the command line, it will present the contents of the TicketGet() call.

I created a dynamic field on a ticket called 'MyTicketField' and you see it returned, in my case even on the very top of the hash:

=====================================================================
TicketNumber: 2012061610000043
TicketID: 984
Created: 2012-06-16 20:37:27
Queue: Postmaster
State: open
Priority: 3 normal
Lock: unlock
---------------------------------------------------------------------
ArticleID: 6427
From: OTRS System <otrs@localhost>
To: my.cu...@otrs.com,
Subject: [Ticket#2012061610000043] Test ticket subject
Created: 2012-06-16 20:37:27
SenderType: agent
Body:
Test ticket body

Your Ticket-Team

Michiel Beijen

--
Super Support - Waterford Business Park
5201 Blue Lagoon Drive - 8th Floor & 9th Floor - Miami, 33126 USA
Email: h...@example.com - Web: [1]http://www.example.com/
--

[1] http://www.example.com/

---------------------------------------------------------------------
$VAR1 = {
          'DynamicField_MyTicketField' => 'My Dynamic Field Contents',
          'Age' => 165,
          'PriorityID' => 3,
          'ServiceID' => '',
          'DynamicField_TicketFreeText3' => undef,
          'Type' => 'default',
          'Responsible' => 'root@localhost',
          'StateID' => 4,
          'ResponsibleID' => 1,
          'DynamicField_TicketFreeText1' => undef,
          'ChangeBy' => 2,
          'EscalationTime' => 0,
          'DynamicField_TicketFreeTime6' => undef,
          'OwnerID' => 2,
          'Changed' => '2012-06-16 20:37:27',
          'RealTillTimeNotUsed' => 0,
          'GroupID' => 1,
          'Owner' => 'michiel',
          'CustomerID' => undef,
          'DynamicField_TicketFreeKey3' => undef,
          'TypeID' => 1,
          'Created' => '2012-06-16 20:37:27',
          'Priority' => '3 normal',
          'UntilTime' => 0,
          'EscalationUpdateTime' => 0,
          'DynamicField_TicketFreeTime1' => undef,
          'QueueID' => 1,
          'Queue' => 'Postmaster',
          'State' => 'open',
          'Title' => 'Test ticket subject',
          'CreateBy' => 2,
          'TicketID' => 984,
          'StateType' => 'open',
          'DynamicField_TicketFreeText2' => undef,
          'UnlockTimeout' => 1339871847,
          'EscalationResponseTime' => 0,
          'EscalationSolutionTime' => 0,
          'DynamicField_TicketFreeKey1' => undef,
          'LockID' => 1,
          'TicketNumber' => '2012061610000043',
          'ArchiveFlag' => 'n',
          'CreateTimeUnix' => 1339871847,
          'Lock' => 'unlock',
          'SLAID' => '',
          'CustomerUserID' => undef
        };


Hope this helps!

--
Mike

Bernard Chambon

unread,
Jun 21, 2012, 6:50:53 AM6/21/12
to User questions and discussions about OTRS.
Hello,

I want to create several 'Dropdown' dynamic fields with many values each one
Is it possible to do it without the GUI ? (too tedious !)

The main question is where are stored the values ?
I create one with 2 values , but I can find where they are ?
Not in dynamic_field_value ?
mysql> select * from dynamic_field_value  ;
Empty set (0.00 sec)

The only entry is in dynamic_field

mysql> select * from dynamic_field where ...
*************************** 1. row ***************************
         id: 10
       name: ToTestStorageInDB
      label: ToTestStorageInDB
field_order: 9
 field_type: Dropdown
object_type: Ticket
     config: ---
DefaultValue: ''
Link: ''
PossibleNone: 0
PossibleValues:
  Key1: Value1
  Key2: Value2
TranslatableValues: 0

   valid_id: 1
create_time: 2012-06-21 12:14:48
  create_by: 1
change_time: 2012-06-21 12:14:48
  change_by: 1
1 row in set (0.00 sec)



I did not find anything in otrs/bin/

Best regards

Bernard Chambon

unread,
Jun 21, 2012, 7:41:20 AM6/21/12
to User questions and discussions about OTRS.
Hello,

And sorry, I need a pair of glasses  !
The values are stores in the dynamic_field table see BLOB column ' config'

     config: ---
DefaultValue: ''
Link: ''
PossibleNone: 0
PossibleValues:
  Key1: Value1
  Key2: Value2
TranslatableValues: 0



sorry for the (previous) spam

Regards

---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

Bernard Chambon

unread,
Jun 27, 2012, 9:26:23 AM6/27/12
to User questions and discussions about OTRS.
Hello,

Le 16 juin 2012 à 20:46, Michiel Beijen a écrit :

Hi Bernard,

Typically you dump the contents of data structures with a module like Data::Dumper.

So if you'd take the file bin/otrs.GetTicketThread.pl which is on your OTRS system, this utility prints out a ticket to the screen.
If you would open this file in a text editor, set DynamicFields to '1' and then add, at the end of the file, these two lines:

 use Data::Dumper;
 print Dumper (\%Ticket);

and then run bin/otrs.GetTicketThread.pl [TicketID] on the command line, it will present the contents of the TicketGet() call.


Thank you for that help.

now other question :
 using several dyn fields, Is there a way to known which one has been modified
 Or do I have to process all dynamic fields, even if only one has changed
 (I mean now using event, still working with generic Agent.)

Michiel Beijen

unread,
Jun 27, 2012, 9:36:16 AM6/27/12
to User questions and discussions about OTRS.
Hi Bernard,

On Wed, Jun 27, 2012 at 3:26 PM, Bernard Chambon
<bernard...@cc.in2p3.fr> wrote:
> now other question :
>  using several dyn fields, Is there a way to known which one has been
> modified
>  Or do I have to process all dynamic fields, even if only one has changed
>  (I mean now using event, still working with generic Agent.)

You can bind to the event for this specific field. If your register
your event module for the event
TicketDynamicFieldUpdate_IsCompanyTicket it would only be triggered if
this field is updated.

Kindest regards,

Michiel Beijen
Senior Consultant

OTRS BV
Schipholweg 103
2316 XC Leiden
The Netherlands

T: +31 71 8200 255
F: +31 71 8200 254
I: http://www.otrs.com

Get Connected ! Everything in sync with OTRS 3.1- Be an early bird
with our special offer: http://j.mp/xN9wk1

Reply all
Reply to author
Forward
0 new messages