Scrip Condition: Untake?

Greetings RT Forum & Happy June for those that begin the summer months like us northerners!

I’m attempting to make a Scrip with conditional logic if a ticket is “Untaken”, but it would seem there is no transaction type for Untake, as this does not evaluate true on Untake action:

TransactionObj->Type eq "Untake"

Any thoughts on how this can be accomplished?

The easiest was is to make Nobody the owner.

So you want to detect if the user changed to ‘nobody’ because “Untake” is the same as setting to ‘nobody’. Right?

Got two solutions in my mind:

  • Use logging to write the TransactionObj->Field or TransactionObj->Type to the logfile. I dont know the value for OwnerChange, too. See example below how to use logging. Then use $self->TransactionObj->OldValue !~ /nobody/i;and $self->TransactionObj->NewValue =~ /nobody/i; to test for “untake”.

  • Second is to use ‘On Owner Change’ and test for Owner “Nobody”. So if “Owner Change” is true there must be an other owner than ‘nobody’ before.

Example:
Condition: On Owner Change
Custom action praparation code:

my $ticket = $self->TicketObj;
my $log_tag = $ticket->QueueObj->Name . "#" . $ticket->id; 
my $owner_id = $self->TicketObj->Owner();

$RT::Logger->info($log_tag . ": Preparation. Owner is"  . $owner_id);

return 1 unless ($owner_id == 10);
return 0;

Custom action commit code:
Whatever you want to do.

Thank you! This pointed me in the right direction.

I was looking for way to resolve a bug in the “RT-Action-AssignUnownedToActor” plugin which is triggered by attempting to Untake a ticket where you’re the owner (and not the requester). If you try this the plugin assigns you back to the owner after you Untake the ticket so it makes a kinda loop.

This diff of “AssignUnownedToActor.pm” contains the resolution I have tested & confirmed to work:

14a15,18
>     # where the action is not already an owner change
>     # Specifically, this is to corect a bug where this extension breaks "Untake" functionality
>     return 0 if $self->TransactionObj->Type eq "Set" && $self->TransactionObj->Field eq "Owner";
>

Once the above line is added, you also need to move the scrip (with action “Assign unowned tickets to actor”) to be a batch scrip, otherwise it won’t work.

Not sure how I would go about getting the above changeset applied upstream to BP github (rt-action-assignunownedtoactor/lib/RT/Action/AssignUnownedToActor.pm at master · bestpractical/rt-action-assignunownedtoactor · GitHub).

Once the above is merged this can also be closed out:
https://rt.cpan.org/Public/Bug/Display.html?id=145546

Many thanks for pointing me in the right direction