Scrip SetTimeWorked by user


I’m working on script that calculate’s the “Time Worked” in every status change from “Working” (it’s a new status created in a new lifecycle) to any status and updates the “Time Worked” automatically with de difference between the status transitions dates (I used two hidden fields for save the transitions date values)

The scrip works fine, but when change the status the “Time Worked” in the ticket appears the user “RT_System” and not the user that is doing the status change (or the owner of the ticket).

The part of code that “fails” it’s this:

$TicketObj->SetTimeWorked( $OldTimeWorked + $NewTimeWorked );

I’m trying a lot of things for make this works in the way I want, I’m search in the forum, doc, wiki, and google/duckduckgo but my knowledge about perl and dev it’s not enough for doing this works.

Therefore, I am here as the last option to ask for help or information to help me solve this problem.

By the way, the version I use of RT is 4.1.1.

Thanks in advance.

You can use $self->TransactionObj->CreatorObj to get the actor.

Do you get an error?

1 Like

Thanks for the answer.

I don’t have any error, only the user that appears in the “Time Worked” is “RT_System”.

I have tried to use this with SetTimeWorked but I don’t know how to use with CreatorObj :confused:

Thanks in advance.

I haven’t tried it but I think you would load a new ticket object where the user creating the ticket object is the current actor. Then you can load the ticket from the $TicketObj->Id and set the time worked using the new ticket object that has the correct context

1 Like