
########################
TicketAttributeRelations
########################


****************
PUBLIC INTERFACE
****************


new()
=====


create an object


.. code-block:: perl

     my $TicketAttributeRelationsObject = $Kernel::OM->Get('Kernel::System::TicketAttributeRelations');



AddTicketAttributeRelations()
=============================


Adds a new ticket attribute relations record.


.. code-block:: perl

     my $ID = $TicketAttributeRelationsObject->AddTicketAttributeRelations(
         Filename                 => 'csv-filename.csv',
         Data                     => 'Data from CSV or Excel file',
         DynamicFieldConfigUpdate => 1, # optional, this option will create dynamic field values for the CSV file
         Priority                 => 123,
         UserID                   => 123,
     );


Returns ID of created record on success.


.. code-block:: perl

     my $ID = 1;



ExistsTicketAttributeRelationsFilename()
========================================


Checks if a ticket attribute relations record with the given filename exists.


.. code-block:: perl

     my $ID = $TicketAttributeRelationsObject->ExistsTicketAttributeRelationsFilename(
         Filename => 'test1.csv',
     );


Returns the ID of the found record or 0 if not found.


.. code-block:: perl

     my $ID = 1;



GetTicketAttributeRelations()
=============================


Fetches a ticket attribute relations record.


.. code-block:: perl

     my $TicketAttributeRelations = $TicketAttributeRelationsObject->GetTicketAttributeRelations(
         ID         => 123,
         # or
         # Filename => 'test.csv',
         UserID     => 1,
     );


Returns:


.. code-block:: perl

     my $TicketAttributeRelations = {
         ID         => 41,
         Filename   => 'csv-filename.csv',
         Priority   => 4,
         Attribute1 => 'Queue',
         Attribute2 => 'DynamicField_test',
         Data       => [
             {
                 'Queue'             => 'abc',
                 'DynamicField_test' => 'bcd',
             },
         ],
         RawData     => '...', # original content of uploaded file
         CreatedTime => '...',
         CreatedBy   => 2,
         ChangeTime  => '...',
         ChangedBy   => 4,
     };



UpdateTicketAttributeRelations()
================================


Updates an existing ticket attribute relations record.


.. code-block:: perl

     my $Success = $TicketAttributeRelationsObject->UpdateTicketAttributeRelations(
         ID                       => 123,
         Filename                 => 'csv-filename.csv',
         Data                     => 'Data from CSV or Excel file',
         DynamicFieldConfigUpdate => 1, # optional, this option will create dynamic field values for the csv file
         Priority                 => 123,
         UserID                   => 123,
     );


Returns true value on success.


.. code-block:: perl

     my $Success = 1;



GetAllTicketAttributeRelations()
================================


Fetches data of all ticket attribute relation records, sorted by priority.


.. code-block:: perl

     my $TicketAttributeRelations = $TicketAttributeRelationsObject->GetAllTicketAttributeRelations(
         UserID => 123,
     );


Returns:


.. code-block:: perl

     my $TicketAttributeRelations = [
         {
             ID         => 41,
             Filename   => 'csv-filename.csv',
             Priority   => 1,
             Attribute1 => 'Queue',
             Attribute2 => 'DynamicField_test',
             Data       => [
                 {
                     'Queue'             => 'abc',
                     'DynamicField_test' => 'bcd',
                 },
             ],
             RawData     => '...', # original content of uploaded file
             CreatedTime => '...',
             CreatedBy   => 2,
             ChangeTime  => '...',
             ChangedBy   => 4,
         },
         {
             ID         => 7,
             Filename   => 'csv-filename-2.csv',
             Priority   => 2,
             Attribute1 => 'Queue',
             Attribute2 => 'DynamicField_test',
             Data       => [
                 {
                     'Queue'             => 'abc',
                     'DynamicField_test' => 'bcd',
                 },
             ],
             RawData     => '...' # original content of uploaded file
             CreatedTime => '...',
             CreatedBy   => 2,
             ChangeTime  => '...',
             ChangedBy   => 4,
         },
         # ...
     ];



DeleteTicketAttributeRelations()
================================


Deletes a ticket attribute relations record.


.. code-block:: perl

     my $Success = $TicketAttributeRelationsObject->DeleteTicketAttributeRelations(
         ID     => 123,
         UserID => 123,
     );


Returns true value on success.


.. code-block:: perl

     my $Success = 1;



_ParseTicketAttributeRelationsData()
====================================


Parses stored ticket attribute relation data.


.. code-block:: perl

     my $ParsedData = $TicketAttributeRelationsObject->_ParseTicketAttributeRelationsData(
         Filename => 'csv_file1.csv', # or Excel file
         Data     => 'Data...',
         UserID   => 123,
     );


Returns:


.. code-block:: perl

     my $ParsedData = {
         Attribute1 => 'DynamicField1',
         Attribute2 => 'DynamicField2',
         Data => [
             {
                 'DynamicField1' => 'abc',
                 'DynamicField2' => 'bcd',
             },
             # ...
         ],
     };



_GenerateTemporaryPriority()
============================


Generates a temporary priority for the given priority to be able to resort priorities
of all existing ticket attribute relation records.


.. code-block:: perl

     my $TempPriority = $TicketAttributeRelationsObject->_GenerateTemporaryPriority(
         Priority         => 5,
         PreviousPriority => 7, # optional
     );


Returns:


.. code-block:: perl

     my $TempPriority = 50; # or 52 (see explanation below)



_PreReorderTicketAttributeRelationsPriorities()
===============================================


Temporarily updates priorities of all ticket attribute relations to be able to resort them later.
For explanation, see _GenerateTemporaryPriority().


.. code-block:: perl

     $TicketAttributeRelationsObject->_PreReorderTicketAttributeRelationsPriorities();


Returns true value on success.


.. code-block:: perl

     my $Success = 1;



_PostReorderTicketAttributeRelationsPriorities()
================================================


Updates priorities of all ticket attribute relations to finalize resorting.
For explanation, see _GenerateTemporaryPriority().


.. code-block:: perl

     $TicketAttributeRelationsObject->_PostReorderTicketAttributeRelationsPriorities();


Returns true value on success.


.. code-block:: perl

     my $Success = 1;



_UpdateDynamicFieldConfigs()
============================


Updates the dynamic field configuration based on the ticket attribute relation configuration.


.. code-block:: perl

     my $Success = $TicketAttributeRelationsObject->_UpdateDynamicFieldConfigs(
         TicketAttributeRelationsID => 123,
         UserID                     => 123,
     );


Returns true value on success.


.. code-block:: perl

     my $Success = 1;



_IsExcelFilename()
==================


Checks if the given filename has an Excel extension.


.. code-block:: perl

     my $IsExcelFilename = $TicketAttributeRelationsObject->_IsExcelFilename(
         Filename => 'test.xlsx',
     );


Returns true value if the given name has an Excel extension.


.. code-block:: perl

     my $IsExcelFilename = 1;



_Excel2ArrayTicketAttributeRelationsData()
==========================================


Returns an array for the given Excel file data.


.. code-block:: perl

     my $Data = $TicketAttributeRelationsObject->_Excel2ArrayTicketAttributeRelationsData(
         Data => '...',
     );


Returns:


.. code-block:: perl

     my $Data = [
         {
             'DynamicField1' => 'abc',
             'DynamicField2' => 'bcd',
         },
         # ...
     ],



_ImportExcelValue()
===================


Encodes the given imported Excel file value and converts it too ASCII.


.. code-block:: perl

     my $ImportedValue = $TicketAttributeRelationsObject->_ImportExcelValue($Value);
 
     Returns encoded/converted value.




