Help with scrip using DiffAsString

To list,

I’m trying to create a scrip that gives me the difference between the
started date and the resolved date when the ticket is resolved:

This is my scrip:

Condition: On Resolve
Action: User-defined
Template: Blank
Stage: TransBatch

Custom Prep Code:
return 1;

Custom Cleanup Code:

Set initial values

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $timeworked = $ticket->TimeWorked;
my $started = $ticket->StartedObj;
my $now = new RT::Date($RT::SystemUser);
my $worked = $now->DiffAsString($started);

Set value for TimeWorked if not already set

unless ($timeworked)
return 1;
return 0;

This was what was in the log:


‘Field’, ‘TimeWorked’, ‘Value’, ‘5 sec’, ‘IsSQL’, ‘undef’) called at
/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Record/ line
‘Field’, ‘TimeWorked’, ‘Value’, ‘5 sec’, ‘IsSQL’, ‘undef’) called at
/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/ line 745
DBIx::SearchBuilder::Record::_Set(‘RT::Ticket=HASH(0xcfbcfe0)’, ‘Field’,
‘TimeWorked’, ‘Value’, ‘5 sec’, ‘IsSQL’, ‘undef’) called at
/opt/rt3/bin/…/local/lib/RT/ line 482
RT::Record::_Set(‘RT::Ticket=HASH(0xcfbcfe0)’, ‘Field’, ‘TimeWorked’,
‘Value’, ‘5 sec’) called at /opt/rt3/bin/…/lib/RT/ line
3313 RT::ticket::_Set(‘RT::Ticket=HASH(0xcfbcfe0)’, ‘Field’,
‘TimeWorked’, ‘Value’, ‘5 sec’) called at
/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/ line 440
DBIx::SearchBuilder::Record::ANON(‘RT::Ticket=HASH(0xcfbcfe0)’, ‘5 sec’)
called at (eval 595) line 16 eval '# Set initial values
my $trans = $self->TransactionObj;my $ticket = $self->TicketObj;my
$timeworked = $ticket->TimeWorked;
my $started = $ticket->StartedObj;#my $duration = ‘DAY’;my $now = new
RT::Date($RT::SystemUser);$now->SetToNow();my $worked =

Set value for TimeWorked if not already set

unless ($timeworked) { $ticket->SetTimeWorked($worked); return
1; }
return 0;’ called at /opt/rt3/bin/…/lib/RT/Action/ line 78

I don’t understand where the “…‘Value’, ‘5 sec’” came from.

I also tried this with “Diff” and I get a resulting value.

Anyone have any idea what I’m doing wrong.

I wanted to use “Duration” but couldn’t get it to run. I don’t understand
what parms it needs.

Any help would be appreciated.