Re: [rt-users] Add Time difference in search result

2014-08-01 Thread AJ
Hi Alex,

The location path is /html/Callbacks/MyRT/Elements/RT__Ticket/ColumnMap/Once

In the Once file I have contains this:

%init
$COLUMN_MAP-{DifferenceReopenedTime} =  {
title = 'Reopened', # loc
attribute = 'Reopened',
value = sub {
return 'THIS WORKS';
}
};
/%init
%args
$COLUMN_MAP
/%args




--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58141.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-08-01 Thread Alex Peters
I believe that you need to use Reopened in your search and the
BuildFormatString/Default callback, not DifferenceReopenedTime as you
currently have.

#
$RT_ROOT/local/html/Callbacks/MyRT/Search/Elements/BuildFormatString/Default
%INIT
push @{$Fields}, 'Reopened';
/%INIT
%ARGS
$Fields = undef
/%ARGS


On 1 August 2014 17:55, AJ aaron.mccar...@southwestern.ie wrote:

 Hi Alex,

 The location path is
 /html/Callbacks/MyRT/Elements/RT__Ticket/ColumnMap/Once

 In the Once file I have contains this:

 %init
 $COLUMN_MAP-{DifferenceReopenedTime} =  {
 title = 'Reopened', # loc
 attribute = 'Reopened',
 value = sub {
 return 'THIS WORKS';
 }
 };
 /%init
 %args
 $COLUMN_MAP
 /%args




 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58141.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-08-01 Thread AJ
Hi Alex,

I made that change, restarted apache and cleared the cache on my browser but
still nothing after several attempts. Its like its not calling my column map
or something. 

The name of the field stayed as Difference Reopened Time in my search. I
thought that it should have changed to Reopened. I tried looking for a
field called reopen however, there was none.



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58143.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-08-01 Thread Alex Peters
Be sure to clear the server-based Mason cache before restarting the web
server:

http://requesttracker.wikia.com/wiki/CleanMasonCache

as your changes to those files otherwise won't be visible to RT.


On 1 August 2014 19:27, AJ aaron.mccar...@southwestern.ie wrote:

 Hi Alex,

 I made that change, restarted apache and cleared the cache on my browser
 but
 still nothing after several attempts. Its like its not calling my column
 map
 or something.

 The name of the field stayed as Difference Reopened Time in my search. I
 thought that it should have changed to Reopened. I tried looking for a
 field called reopen however, there was none.



 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58143.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-08-01 Thread AJ
I cleared the mason cache, and sure enough 'This works' was displaying. So I
re entered the code you gave me and cleared the mason cache again. However,
'This works' is still displaying. So would the problem be with the code?



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58145.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-08-01 Thread Alex Peters
I suspect that maybe you haven't restarted the web server after clearing
the Mason cache.  Give that a shot; if no luck, errors should be making
their way to the log.


On 1 August 2014 19:58, AJ aaron.mccar...@southwestern.ie wrote:

 I cleared the mason cache, and sure enough 'This works' was displaying. So
 I
 re entered the code you gave me and cleared the mason cache again. However,
 'This works' is still displaying. So would the problem be with the code?



 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58145.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-08-01 Thread AJ
IT WORKS!!! 

You were exactly right in regards to restarting apache.  

Thanks for everything Alex. 

Life saver.

Aaron



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58147.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-07-31 Thread AJ
I'm just using the custom field at the moment to store the date and time of
which a ticket was re opened. I was using this custom field value in the
file I mentioned in the first message along with code I'm using also. I'm
starting to suspect I do not need a custom field. See image of what I have
so far. Is there another way about using this?

http://requesttracker.8502.n7.nabble.com/file/n58112/untitled.bmp 



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58112.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-07-31 Thread Alex Peters
Okay, I understand now: you want to track when a ticket moves from resolved
to open (which isn't recorded automatically), not open to resolved (which
is).

   - You need to obtain access to the ticket here via shift, not $Ticket.
   - One line is missing a terminating semicolon.
   - You can use names when loading custom field values (I'm guessing 13 is
   the ID), but ID works too.
   - The date object needs to be loaded with the time of the field, not the
   current time.
   - The AgeAsString method is provided by the RT::Date object, not the
   ticket.

This code is untested but should be closer to what you want, although it
may need to be tweaked depending on the format in which you write the
custom field value beforehand:

...
value = sub {
  my $ticket = shift;
  my $reopened = $ticket-FirstCustomFieldValue(13);
  my $date = RT::Date-new($RT::SystemUser);
  $date-Set( Format = 'ISO', Value = $reopened );
  return $date-AgeAsString;
}
...


On 31 July 2014 16:53, AJ aaron.mccar...@southwestern.ie wrote:

 I'm just using the custom field at the moment to store the date and time of
 which a ticket was re opened. I was using this custom field value in the
 file I mentioned in the first message along with code I'm using also. I'm
 starting to suspect I do not need a custom field. See image of what I have
 so far. Is there another way about using this?

 http://requesttracker.8502.n7.nabble.com/file/n58112/untitled.bmp



 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58112.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-07-31 Thread AJ
Hi Alex, Thank you for all your help. I really appreciate it.

I used that bit of code, It didn't have to be tweaked (I don't think) as I
used the ISO format for my custom field. However, it does not seem to work.
I can't seem to see where I am going wrong. 

The CustomField is storing the correct datetime. In the search result. Am I
missing something? 



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58121.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-07-31 Thread Alex Peters
That code seems okay to me.  Is you anything useful being reported to RT's
debug log?

Replacing all of that code with:

...
value = sub {
return 'this works';
},
...

could be useful in determining whether the problem lies with that code, or
elsewhere (i.e. how the search result column is being defined and used).
Hi Alex, Thank you for all your help. I really appreciate it.

I used that bit of code, It didn't have to be tweaked (I don't think) as I
used the ISO format for my custom field. However, it does not seem to work.
I can't seem to see where I am going wrong.

The CustomField is storing the correct datetime. In the search result. Am I
missing something?



--
View this message in context:
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58121.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
--
RT Training - Boston, September 9-10
http://bestpractical.com/training
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-07-31 Thread AJ
This is the debug for my scrip which stores the datetime value for the custom
field.

http://requesttracker.8502.n7.nabble.com/file/n58123/Logs.bmp 

As you can see, It is storing the date fine. 

I did as you said and inserted This works into the sub content. Nothing
happened. Didn't see it show up anywhere



--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58123.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-07-31 Thread Alex Peters
If you don't see this works in your search results with that change, then
I'd suspect a problem in how the new column is defined overall.

What's the complete content of the file you're using to define that new
search result column, where are you placing it, and what does your test
search result format look like as shown in the Advanced screen of the
search builder?
On 01/08/2014 12:12 am, AJ aaron.mccar...@southwestern.ie wrote:

 This is the debug for my scrip which stores the datetime value for the
 custom
 field.

 http://requesttracker.8502.n7.nabble.com/file/n58123/Logs.bmp

 As you can see, It is storing the date fine.

 I did as you said and inserted This works into the sub content. Nothing
 happened. Didn't see it show up anywhere



 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58123.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-07-31 Thread AJ
Advanced Search:

Query: Queue = 'Helpdesk' AND (  Status = 'new' OR Status = 'open' )

Format: '   * __id__ __WebPath__/Ticket/Display.html?id=__id__ 
*/TITLE:#',
'* __Subject__ __WebPath__/Ticket/Display.html?id=__id__ 
*/TITLE:Subject',
'__Status__',
'__QueueName__',
'__OwnerName__',
'__Priority__',
'__NEWLINE__',
'',
'small__Requestors__/small',
'small__CreatedRelative__/small',
'small__ToldRelative__/small',
'small__LastUpdatedRelative__/small',
'__DifferenceReopenedTime__'

I have put the new search in
/html/Callbacks/MyRT/Search/Elements/BuildFormatString/
and placed in a file called Default

In this file is:
%INIT
push @{$Fields}, 'DifferenceReopenedTime';
/%INIT
%ARGS
$Fields = undef
/%ARGS

I hope this helps




--
View this message in context: 
http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58130.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training


Re: [rt-users] Add Time difference in search result

2014-07-31 Thread Alex Peters
The search result format string from the Advanced screen of the search
builder looks okay to me.

The file you've referenced only manages the addition of the field to the
select box on the search builder screen, and is presumably in the correct
location and working if your new field is showing up in the select box.

What's the full path to the file with the it works line, and that file's
complete content?
On 01/08/2014 1:44 am, AJ aaron.mccar...@southwestern.ie wrote:

 Advanced Search:

 Query: Queue = 'Helpdesk' AND (  Status = 'new' OR Status = 'open' )

 Format: '   * __id__ __WebPath__/Ticket/Display.html?id=__id__
 */TITLE:#',
 '* __Subject__ __WebPath__/Ticket/Display.html?id=__id__
 */TITLE:Subject',
 '__Status__',
 '__QueueName__',
 '__OwnerName__',
 '__Priority__',
 '__NEWLINE__',
 '',
 'small__Requestors__/small',
 'small__CreatedRelative__/small',
 'small__ToldRelative__/small',
 'small__LastUpdatedRelative__/small',
 '__DifferenceReopenedTime__'

 I have put the new search in
 /html/Callbacks/MyRT/Search/Elements/BuildFormatString/
 and placed in a file called Default

 In this file is:
 %INIT
 push @{$Fields}, 'DifferenceReopenedTime';
 /%INIT
 %ARGS
 $Fields = undef
 /%ARGS

 I hope this helps




 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100p58130.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training

Re: [rt-users] Add Time difference in search result

2014-07-30 Thread Alex Peters
RT automatically stores dates and times into tickets when they are created,
opened and closed.

I notice that you want a relative value (e.g. 40 minutes ago), which
means that that value is only meaningful for a very short time, so perhaps
you're wanting to place it in an outgoing email or something.

Can you tell us more about how you want to use this?  I suspect so far that
a custom field isn't necessary.
On 31/07/2014 1:29 am, AJ aaron.mccar...@southwestern.ie wrote:

 Hi,

 I have made a datetime CustomField. Whenever a ticket is changed from
 open
 to resolve the date and time will be inserted into the custom field.

 However I want it to display the time elapsed e.g. 40 minutes ago etc.

 This is the code I am using in location
 /html/Callbacks/MyRT/Elements/RT__Ticket/ColumnMap

 %init
 $COLUMN_MAP-{DifferenceReopenedTime} =  {
 title = 'Reopened', # loc
 attribute = 'Reopened',
 value = sub {
my $CFValue = $Ticket-FirstCustomFieldValue('13')
my $now = RT::Date-new($RT::SystemUser);
$now-SetToNow();


return $CFValue-AgeAsString();
 }
 };
 /%init
 %args
 $COLUMN_MAP
 /%args

 Can anyone help



 --
 View this message in context:
 http://requesttracker.8502.n7.nabble.com/Add-Time-difference-in-search-result-tp58100.html
 Sent from the Request Tracker - User mailing list archive at Nabble.com.
 --
 RT Training - Boston, September 9-10
 http://bestpractical.com/training

-- 
RT Training - Boston, September 9-10
http://bestpractical.com/training