Adding a custom field in a ticket and displaying it in view

Moderator: crythias

Locked
nishant52
Znuny newbie
Posts: 3
Joined: 12 Jul 2011, 14:40
Znuny Version: 3.0.8
Real Name: Nishant Agarwal

Adding a custom field in a ticket and displaying it in view

Post by nishant52 »

Hi, I want to add a custom field to a ticket . I know that this can be done using FreeTextField.
But, it is for entering text values.
I want the custom field for entering a Date value. A DatePicker should be displayed next to it.

Also, in the Queue View, for e.g. "AgentTicketQueue", I want to add this custom field as a new column.
The user should be able to sort the ticket view based on this custom field value.

Pls let me know how can I do this things.
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Adding a custom field in a ticket and displaying it in v

Post by MichaelR »

It's called a 'TicketFreeTime' field. And can easily be selected/configured.

Sorting by TicketFreeTime in Queue View? Totally different matter, will need some funky coding.

Best bet would be to use the Ticket Search feature!
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
nishant52
Znuny newbie
Posts: 3
Joined: 12 Jul 2011, 14:40
Znuny Version: 3.0.8
Real Name: Nishant Agarwal

Re: Adding a custom field in a ticket and displaying it in v

Post by nishant52 »

MichaelR wrote:It's called a 'TicketFreeTime' field. And can easily be selected/configured.
Thank you Michael for mentioning about 'TicketFreeTime' field.
MichaelR wrote:Sorting by TicketFreeTime in Queue View? Totally different matter, will need some funky coding.

Best bet would be to use the Ticket Search feature!
Did some code change to add the new column in Queue View.

Post at http://forums.otrs.org/viewtopic.php?f=60&t=5156 helped a lot.

I'll post the code changes that I have done to add the new column soon.
nishant52
Znuny newbie
Posts: 3
Joined: 12 Jul 2011, 14:40
Znuny Version: 3.0.8
Real Name: Nishant Agarwal

Re: Adding a custom field in a ticket and displaying it in v

Post by nishant52 »

For adding 'TicketFreeTime1' as a new column in 'AgentTicketQueue', I made changes in following two files:

1. /Kernel/Output/HTML/TicketOverviewSmall.pm
2. /Kernel/Output/HTML/Standard/AgentTicketOverviewSmall.dtl

In "TicketOverviewSmall.pm"
I modified the code

Code: Select all

my @Col = (qw(TicketNumber Age State Lock Queue Owner CustomerID));
as

Code: Select all

my @Col = (qw(TicketNumber Age State Lock Queue Owner CustomerID TicketFreeTime1));
to get the data for new column.

In "AgentTicketOverviewSmall.dtl"
I added a new <th> and <td> element to display the new column

Code: Select all

<!-- dtl:block:OverviewNavBarPageTicketFreeTime1 -->
<th class="$Config{"TicketFreeTimeKey1"} Last $QData{"CSS"}">
      <a name="OverviewControl" href="$Env{"Baselink"}Action=$Env{"Action"};$Data{"LinkSort"};SortBy=TicketFreeTime1; OrderBy=$LQData{"OrderBy"}">$Text{"$Config{"TicketFreeTimeKey1"}"}</a>
</th>
<!-- dtl:block:OverviewNavBarPageTicketFreeTime1 -->
................
................
<td nowrap>
	<div title="$QData{"TicketFreeTime1"}">$Date{"$QData{"TicketFreeTime1"}"}</div>
</td>
grgelisha
Znuny newbie
Posts: 27
Joined: 05 Jul 2011, 14:57
Znuny Version: 2.4.9
Real Name: George Elisha
Company: QLogy Management Services Pvt Ltd

Re: Adding a custom field in a ticket and displaying it in v

Post by grgelisha »

Appreciate if anyone give inputs on how to print values by "Change_time" in "Time1" Column??..
grgelisha
Znuny newbie
Posts: 27
Joined: 05 Jul 2011, 14:57
Znuny Version: 2.4.9
Real Name: George Elisha
Company: QLogy Management Services Pvt Ltd

Re: Adding a custom field in a ticket and displaying it in v

Post by grgelisha »

Hi I have made little changes to the above code

Code: Select all

<!-- dtl:block:OverviewNavBarPageTicketFreeTime1 -->
			<th class="$$Config{"TicketFreeTimeKey1"} Last $QData{"CSS"}">
      			    <a name="OverviewControl" href="$Env{"Baselink"}Action=$Env{"Action"};$Data{"LinkSort"};SortBy=TicketFreeTime1;OrderBy=$LQData{"OrderBy"}">$Text{"Last Update"}</a>
			</th>			
<!-- dtl:block:OverviewNavBarPageTicketFreeTime1 -->
............
                        <td nowrap>
   			   <div title="$QData{"TicketFreeTime1"}">$QData{"Changed"}</div>
			</td>
and in System/Ticket.pm TicketFreeTime1 => 'st.freetime1', is changed to

Code: Select all

TicketFreeTime1        => 'st.change_time',
Locked