Add Custom attribute in stat [SOLVED]

English! place to talk about OTRS development, programming and coding

Moderator: tto

Post Reply
pluwum
OTRS newbie
Posts: 33
Joined: 23 Oct 2012, 16:36
OTRS Version?: 3.1.6
Real Name: patrick
Company: muk

Add Custom attribute in stat [SOLVED]

Post by pluwum » 25 Feb 2013, 15:40

Hello, developers, i would like to pick some data from my otrs DB and display it in my reports i.e display the value as an attribute in stats.
example;
1st- lets say i've altered my otrs database and added a column 'X' to the existing table 'ticket',
2ndly - lets say i want to add a field (MyField) under the "Attributes to be printed:" section in stats such that when selected, the value of X is printed under a column "MyField" in the resulting CSV or PDF or whatever format is available.

Where and how would i have to include the sql statement to pick the value, How would i go about displaying the attribute so that it can be selected and how would i ensure that it is included in the resulting print (csv, pdf etc)?

Please break it down step by step to the simplest bits cause I'm really, really really , reeeeeally ... new to perl and OTRS (however i am not new to programing).
any help with this otrs hack would be greatly appreciated!!!!! cheers.
Last edited by pluwum on 01 Mar 2013, 08:17, edited 1 time in total.

pluwum
OTRS newbie
Posts: 33
Joined: 23 Oct 2012, 16:36
OTRS Version?: 3.1.6
Real Name: patrick
Company: muk

Re: Add Custom attribute in stat

Post by pluwum » 26 Feb 2013, 16:00

anyone there????????!!!!

User avatar
crythias
Moderator
Posts: 9984
Joined: 04 May 2010, 18:38
OTRS Version?: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add Custom attribute in stat

Post by crythias » 28 Feb 2013, 02:14

Look at Kernel/System/Ticket.pm
look at
sub TicketGet

look for a SQL statement
modify it by appending your field(s) after st.change_by

look below there.
add a line (perhaps after $Ticket{ChangeBy})
like
$Ticket{MyField} = $Row[26];
(if that makes sense).

You have now enabled your field to be obtained from TicketGet.

You also need to add this to
Kernel/System/Stats/Dynamic/TicketList.pm
sub _TicketAttributes

MyField => 'MyField',
OTRS 5.0.x (private/testing/public) on Linux with MySQL database. Also on github.
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

pluwum
OTRS newbie
Posts: 33
Joined: 23 Oct 2012, 16:36
OTRS Version?: 3.1.6
Real Name: patrick
Company: muk

Re: Add Custom attribute in stat

Post by pluwum » 01 Mar 2013, 08:15

Thanks soo much. It works. :)

crythias wrote:Look at Kernel/System/Ticket.pm
look at
sub TicketGet

look for a SQL statement
modify it by appending your field(s) after st.change_by

look below there.
add a line (perhaps after $Ticket{ChangeBy})
like
$Ticket{MyField} = $Row[26];
(if that makes sense).

You have now enabled your field to be obtained from TicketGet.

You also need to add this to
Kernel/System/Stats/Dynamic/TicketList.pm
sub _TicketAttributes

MyField => 'MyField',

pluwum
OTRS newbie
Posts: 33
Joined: 23 Oct 2012, 16:36
OTRS Version?: 3.1.6
Real Name: patrick
Company: muk

Re: Add Custom attribute in stat [SOLVED]

Post by pluwum » 01 Mar 2013, 08:19

ooh and i had to add the 'MyField' under the sub _SortedAttributes section in Kernel/System/Stats/Dynamic/TicketList.pm before it showed up on the csv

chaitanyan
OTRS newbie
Posts: 2
Joined: 21 Jun 2018, 22:48
OTRS Version?: 6.0.7

Re: Add Custom attribute in stat

Post by chaitanyan » 28 Jun 2018, 10:32

crythias wrote:
28 Feb 2013, 02:14
Look at Kernel/System/Ticket.pm
look at
sub TicketGet

look for a SQL statement
modify it by appending your field(s) after st.change_by

look below there.
add a line (perhaps after $Ticket{ChangeBy})
like
$Ticket{MyField} = $Row[26];
(if that makes sense).

You have now enabled your field to be obtained from TicketGet.

You also need to add this to
Kernel/System/Stats/Dynamic/TicketList.pm
sub _TicketAttributes

MyField => 'MyField',
Hi, i am using OTRS 6.0.7 with Apache/2.4.6 and i couldn't find the "sub TicketGet" in Kernel/System/Ticket.pm and "sub _TicketAttributes" in Kernel/System/Stats/Dynamic/TicketList.pm.

As i have similar requirement to add new Attribute Column in Statistics, using new Row created on Database table "ticket_state_type" with value "Resolved" and created new State "Restored" using State type.

Now, i would like keep the column with State Type "Resolved", in Statistics and want to keep Timestamp of Tickets updated with State Type "Resolved" on Statistics.

Please help me.
Regards,
Chaitanya.

Post Reply