Storing CustomerUser data in dynamic fields

As described in the OTRS documentation it is possible to take customer information, for example from an LDAP Backend, to a dynamic field when a ticket is created or the customer is changed. This could later be used for reporting and would preserve the value from the time of ticket creation, even when it is changed in the LDAP backend.

Unfortunately the documentation is not that detailed, especially if you new to OTRS. So here is a little more information on how to do this.

In my case I have the cost center information in the Active Directory field departmentNumber which I’d like to preserve for each ticket, for future reporting.

Here is a part from my Cutomer LDAP Attribute mapping from

$Self->{CustomerUser1} = {
    Map => [
      # note: Login, Email and CustomerID needed!
      # var, frontend, storage, shown, required, storage-type
      [ 'UserFirstname', 'Firstname', 'givenname', 1, 1, 'var' ],
      [ 'UserLastname', 'Lastname', 'sn', 1, 1, 'var' ],
      [ 'UserCostCenter', 'CostCenter', 'departmentNumber', 0, 0, 'var' ],

I’ve created a Ticket DynamicField of type Text named CostCenter which will hold the information. My Label is in German…


I’d like to show the cost center information on Free Text pop up and on Ticket Zoom in the Ticket Information area.

$Self->{'Ticket::Frontend::AgentTicketFreeText'}->{'DynamicField'} =  {
   'CostCenter' => '1',
$Self->{'Ticket::Frontend::AgentTicketZoom'}->{'DynamicField'} =  {
   'CostCenter' => '1',

If you already have one of the settings mentioned, you have to add the new values instead of adding the entire setting, otherwise it will only take the last value from the and ignore other settings.

You could show the DynamicField on Customer Ticket Zoom as well:

$Self->{'Ticket::Frontend::CustomerTicketZoom'}->{'DynamicField'} =  {
   'CostCenter' => '1',

Now we have to enable the module which does the actual work by storing the customer data to the dynamic field. You can do this in SysConfig or by adding the following to

$Self->{'Ticket::EventModulePost'}->{'930-DynamicFieldFromCustomerUser'} =  {
  'Event' => '(TicketCreate|TicketCustomerUpdate)',
  'Module' => 'Kernel::System::Ticket::Event::DynamicFieldFromCustomerUser'

Finally we define which User Information is stored in which DynamicField:

$Self->{'DynamicFieldFromCustomerUser::Mapping'} =  {
  'UserCostCenter' => 'CostCenter'

The mapping references the var from the Customer backend mapping with the name of our DynamicField.

Thats it. You can test it by changing the Customer of a Ticket, the Info should now be in Ticket Free Text and in Ticket Zoom.

Have Fun