[rt-users] Scrip - On close set CF to owner name and then change owner to nobody
bart at pleh.info
Wed Oct 5 05:16:24 EDT 2011
After some more testing the below scrip doesn't seem to do what it should..
It now does work but it fills in the wrong user. Sometimes a colleague of
mine instead of myself, while I'm the person hitting "Resolved". Or
sometimes root, I guess because it runs a scrip when closing and the actual
last actioning user almost always is root.
Is there better, more clever, way for getting the actioning user "or" the
ticket owner into a CF during ticket resolve and afterwards setting the
owner to nobody?
2011/10/4 Bart <bart at pleh.info>
> Never mind...
> I just stumbled upon the CreatorObj.
> Changed the scrip to the following:
> my $my_owner = $self->TicketObj->CreatorObj->Name;
>> $self->TicketObj->AddCustomFieldValue(Field => 'Last Owner', Value =>
>> my ($code, $msg) = $self->TicketObj->SetOwner(6, 'Force');
>> return 1;
> This gave me the result I wanted it to have :-)
> Problem solved.
> -- Bart
> 2011/10/4 Bart <bart at pleh.info>
>> I'm currently struggling with this scrip, in separate parts it works but
>> together it kinda makes a mess O_o
>> Some background on the scrip. We want the ticket owner to be set to Nobody
>> on close, when tickets reopen they will show up in the New/nobody queue for
>> everyone in a support group to pickup instead of the previous owner.
>> But, we do want the ability to make a simple search query on resolved
>> tickets and sort them by owner. Basically for our managers so they can see
>> if the tickets are distributed evenly, etc.
>> For that purpose I figured I could fill in the owner name into a CF and
>> have the actual owner set to nobody.
>> Below the scrip:
>> my $my_owner = $self->TicketObj->OwnerObj->Name;
>>> $self->TicketObj->AddCustomFieldValue(Field => 'Last Owner', Value =>
>>> my ($code, $msg) = $self->TicketObj->SetOwner(6, 'Force');
>>> return 1;
>> What happens is that the first two lines fill the current owner's name
>> into a CF called "Last Owner".
>> After that it should change the owner to Nobody, in my case the UID of
>> Nobody is number 6. I've set it to force since it doesn't always work
>> correctly if you leave the force bit out.
>> When I run this scrip separately it works, I can set the owner to nobody +
>> if I leave the last bit out I'm able to set the current owner in the CF
>> called "Last Owner".
>> But when using them together as shown in the scrip above it doesn't work
>> the way I want it to.
>> It then seems to first set the owner to nobody and then fill the CF with
>> the username Nobody... So yes it works but I'm expecting the scrip to first
>> get the old owner name and fill that one into the CF.
>> I've also tried setting this first part into the "prep" code and the
>> second part (changing the owner) into the cleanup code, but that doesn't
>> seem to change anything.
>> The other thing I've tried was changing the TransactionBatch to
>> TransactionCreate and back. With TransactionCreate it doesn't fully work,
>> when using TransactionBatch it does work but instead of the previous ticket
>> owner it fills in the Nobody user...
>> So, does anyone know a simple way to fix this? I'm expecting RT to
>> sequentially do the above scrip but I guess I'm missing something in order
>> for it to work.
>> Thanks in advance.
>> -- Bart
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rt-users