[SOLVED] Custom fields in statistics.

Moderator: crythias

Locked
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

[SOLVED] Custom fields in statistics.

Post by Lubomirsb »

How i can add fields in reports (fields which i created manually in Config.pm)

Code: Select all

$Self->{CustomerCompany} = {
        Params => {
            # if you want to use an external database, add the
            # required settings
#            DSN  => 'DBI:odbc:yourdsn',
#            Type => 'mssql', # only for ODBC connections
#            DSN => 'DBI:mysql:database=customerdb;host=customerdbhost',
#            User => '',
#            Password => '',
            Table => 'customer_company',
#            ForeignDB => 0,    # set this to 1 if your table does not have create_time, create_by, change_time and change_by fields

            # CaseSensitive will control if the SQL statements need LOWER()
            #   function calls to work case insensitively. Setting this to
            #   1 will improve performance dramatically on large databases.
            CaseSensitive => 0,
        },

        # company unique id
        CustomerCompanyKey             => 'customer_id',
        CustomerCompanyValid           => 'valid_id',
        CustomerCompanyListFields      => [ 'customer_id', 'name' ],
        CustomerCompanySearchFields    => ['customer_id', 'name'],
        CustomerCompanySearchPrefix    => '',
        CustomerCompanySearchSuffix    => '*',
        CustomerCompanySearchListLimit => 250,
        CacheTTL                       => 0, # use 0 to turn off cache

        Map => [
            # var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly
            [ 'CustomerID',             'CustomerID', 'customer_id', 0, 1, 'var', '', 0 ],
            [ 'CustomerCompanyName',    'Company',    'name',        1, 1, 'var', '', 0 ],
	     [ 'CustomerOracleVersion',      'Oracle version',     'oracle_version',     1, 0, 'var', '', 0 ],
	     [ 'OraclePassword',   'Oracle password',     'oracle_password',     1, 0, 'var', '', 0 ],
	     [ 'CustomerServerParameters',   'Server parameters',     'server_parameters',     1, 0, 'var', '', 0 ],
	     [ 'Connetctions',   'Connetctions',     'connections',     1, 0, 'var', '', 0 ],
	     [ 'WindowsVersion',   'Windows version',     'windows_version',     1, 0, 'var', '', 0 ],	     
	     [ 'CustomerManager',   'Manager',     'manager',     1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyStreet',  'Street',     'street',      1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyZIP',     'Zip',        'zip',         1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyCity',    'City',       'city',        1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyCountry', 'Country',    'country',     1, 0, 'var', '', 0 ],
            [ 'CustomerCompanyURL',     'URL',        'url',         1, 0, 'var', '$Data{"CustomerCompanyURL"}', 0 ],
            [ 'CustomerCompanyComment', 'Comment',    'comments',    1, 0, 'var', '', 0 ],
            [ 'ValidID',                'Valid',      'valid_id',    0, 1, 'int', '', 0 ],
        ],
    };

Oracle version ,Oracle password,Server parameters ,Connetctions and Windows version are my custom fileds in customer company . OTRS store them properly in the database.
So the question is how i can print this fields in reports or use these fields to make reports based on them ?
Last edited by Lubomirsb on 12 Dec 2013, 11:19, edited 1 time in total.
OTRS 3.3.4 ,Centos 6.5
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

Any help please ?
OTRS 3.3.4 ,Centos 6.5
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

Progress so far :

1. I found this viewtopic.php?f=64&t=19419&p=76281&hilit=reports#p76281 which is exactly what i want to do !
2. I did everything in there and now i can see my field "ErpVersion" in the reports , but its empty ?!?!

My sql i slight different from this in the thread because i dont have a new column in the database. Instead of that i use JOIN here is the sql

Code: Select all

SELECT st.id, st.queue_id, st.ticket_state_id, st.ticket_lock_id, st.ticket_priority_id,
                    st.create_time_unix, st.create_time, st.tn, st.customer_id, st.customer_user_id,
                    st.user_id, st.responsible_user_id, st.until_time, st.change_time, st.title,
                    st.escalation_update_time, st.timeout, st.type_id, st.service_id, st.sla_id,
                    st.escalation_response_time, st.escalation_solution_time, st.escalation_time, st.archive_flag,
                    st.create_by, st.change_by, customer_user.erp_version
                FROM ticket st
	         JOIN customer_user ON customer_user.login = st.customer_user_id
                WHERE st.id = ?',
            Bind  => [ \$Param{TicketID} ],
            Limit => 1,

Any ideas ?
OTRS 3.3.4 ,Centos 6.5
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom fields in statistics.

Post by crythias »

Did you see the followup of sub _SortedAttributes?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

It seems like there is a value but only for the last edited or created tickets ? I dont understand ...i tried the sql everything is fine but in OTRS its not...
OTRS 3.3.4 ,Centos 6.5
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

crythias wrote:Did you see the followup of sub _SortedAttributes?

Code: Select all

sub _SortedAttributes {
    my $Self = shift;

    my @SortedAttributes = qw(
        Number
        TicketNumber
        Age
        Title
        Created
        Changed
        Closed
        Queue
        State
        Priority
        CustomerUserID
        CustomerID
        Service
        SLA
        Type
        Owner
        Responsible
        AccountedTime
        EscalationDestinationIn
        EscalationDestinationTime
        EscalationDestinationDate
        EscalationTimeWorkingTime
        EscalationTime

        FirstResponse
        FirstResponseInMin
        FirstResponseDiffInMin
        FirstResponseTimeWorkingTime
        FirstResponseTimeEscalation
        FirstResponseTimeNotification
        FirstResponseTimeDestinationTime
        FirstResponseTimeDestinationDate
        FirstResponseTime

        UpdateTimeEscalation
        UpdateTimeNotification
        UpdateTimeDestinationTime
        UpdateTimeDestinationDate
        UpdateTimeWorkingTime
        UpdateTime

        SolutionTime
        SolutionInMin
        SolutionDiffInMin
        SolutionTimeWorkingTime
        SolutionTimeEscalation
        SolutionTimeNotification
        SolutionTimeDestinationTime
        SolutionTimeDestinationDate
        SolutionTimeWorkingTime

        FirstLock
        Lock
        StateType
        UntilTime
        UnlockTimeout
        EscalationResponseTime
        EscalationSolutionTime
        EscalationUpdateTime
        RealTillTimeNotUsed
	 ErpVersion
    );

ErpVersion is the filed, yes its there .
OTRS 3.3.4 ,Centos 6.5
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom fields in statistics.

Post by crythias »

values might show up differently because of cacheing. (?)
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

crythias wrote:values might show up differently because of cacheing. (?)
There are only 3 values , everything else is just empty . If its because of caching how i can turn of cache for statistics ?
OTRS 3.3.4 ,Centos 6.5
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom fields in statistics.

Post by crythias »

try otrs/bin/otrs.DeleteCache.pl
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

crythias wrote:try otrs/bin/otrs.DeleteCache.pl
This one fixed the problem , but how i can disable this cache ?
OTRS 3.3.4 ,Centos 6.5
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Custom fields in statistics.

Post by crythias »

disable? cache is for performance. Since you've already determined new entries "stick", and clearing the cache (old data before you made changes) fixed the issue for you then you shouldn't need to worry about cache having a problem again -- while you use the same fields.

Also, var/cron/cache deletes every Sunday.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Lubomirsb
Znuny newbie
Posts: 83
Joined: 15 Nov 2013, 15:19
Znuny Version: 4.0.13
Real Name: Lubomir
Company: Expert-M

Re: Custom fields in statistics.

Post by Lubomirsb »

crythias wrote:disable? cache is for performance. Since you've already determined new entries "stick", and clearing the cache (old data before you made changes) fixed the issue for you then you shouldn't need to worry about cache having a problem again -- while you use the same fields.

Also, var/cron/cache deletes every Sunday.
Thanks a lot !!!! Problems solved !
OTRS 3.3.4 ,Centos 6.5
Locked