Add incremental time worked in a scrip

Hi all,

I want to increment the time worked of a ticket during execution of a scrip
that fires with the “On Correspond” condition by adding time for just that
transaction.

I can’t see a way to set the time worked for just the specific transaction
that is active during the life of the scrip.

The following line of code:

$self->TicketObj->SetTimeWorked( $self->TicketObj->TimeWorked + $mins );

does increment the TimeWorked of the ticket, but that time is not allocated
to that comment.

I bet this is really easy, but I’m stumped. The wiki didn’t help me either.

Any pointers?

Thanks,
Gary

Gary,

➢ I bet this is really easy, but I’m stumped. The wiki didn’t help me either.

If you want to associate times with comments, you need to make sure they are stored inside the corresponding transactions. However transaction objects are immutable, so you probably can’t modify them from Scrips. I think you will need to intercept a callback in ticket update and update ticket parameters (UpdateTimeWorked) before they enter the RT core.

Best regards,
Maciek

Dnia 2012-09-11, wto o godzinie 17:51 +0200, Maciej Dobrzanski pisze:

Gary,

➢ I bet this is really easy, but I’m stumped. The wiki didn’t help me either.

If you want to associate times with comments, you need to make sure they are stored inside the corresponding transactions. However transaction objects are immutable, so you probably can’t modify them from Scrips. I think you will need to intercept a callback in ticket update and update ticket parameters (UpdateTimeWorked) before they enter the RT core.

I think TransactionBatch scrips are meant to do that.

Regards,
Robert Wysocki
administrator systemów linuksowych
Contium S.A., http://www.contium.pl

Dnia 2012-09-11, wto o godzinie 17:51 +0200, Maciej Dobrzanski pisze:

Gary,

➢ I bet this is really easy, but I’m stumped. The wiki didn’t help me either.

If you want to associate times with comments, you need to make sure
they are stored inside the corresponding transactions. However
transaction objects are immutable, so you probably can’t modify them
from Scrips. I think you will need to intercept a callback in ticket
update and update ticket parameters (UpdateTimeWorked) before they
enter the RT core.

I think TransactionBatch scrips are meant to do that.

TransactionBatch scrips just run after all the transactions in an
update are done, they don’t have to do with changing transactions.
Also, the TransactionBatch scrip would require you to iterate through
all the related transactions to find the right one to update, while
the On Correspond scrip living in TransactionCreate would get the
right transaction automatically.

As noted by Maciej - far and away the easiest thing is to use a
callback or some JS to insert a default into the UpdateTimeWorked on
Update.html. You can do it from a Scrip, but you have to use a hammer
to update the Transactions.

-kevin