I have a script to check if a ticket has DependedOnBy tickets, and if it has, I want to get the queue name for that ticket and check if it’s a specific queue name. I’ve created the script below, but it’s not working properly and I don’t know what I’m doing wrong. It stops after the first loop, and only check the queue for the current ticket
PS: If I use the same script to check for a parent ticket (MemberOf), it’s working fine. If I create a child ticket from a parent ticket. But If I create a DependsOn ticket, it will not work anymore.
e.g my $DependedOnBy = $ticket->MemberOf;
my $txn = $self->TransactionObj;
my $type = $txn->Type;
return 0 unless $type eq "Status";
$RT::Logger -> info("SCRIP #77 CHECk IF DependedOnBy Q IS Q_Name");
my $ticket = $self->TicketObj;
my $DependedOnBy = $ticket-> DependedOnBy;
return 0 unless $DependedOnBy;
while( my $dependedOnBy = $DependedOnBy->Next )
{
my $dependedOnByQueueName = $dependedOnBy->TargetObj->QueueObj->Name;
$RT::Logger -> info("SCRIPT #77 CHECK FOR DependedOnBy -- ${dependedOnByQueueName}");
if($dependedOnByQueueName eq "Q_Name") {
$RT::Logger->info("SCRIP #77 - QUEUE IS ${dependedOnByQueueName}");
return 1;
}
$RT::Logger -> info("SCRIP #77 - There is no DependedOnBy ticket in Q Q_Name");
}
$RT::Logger -> info("END OF SCRIP #77 CHECk IF DependedOnBy Q IS Q_Name");
return 0;
UPDATE - SOLUTION:
Change the TargetObjmy $dependedOnByQueueName = $dependedOnBy->TargetObj->QueueObj->Name;. with BaseObjmy $dependedOnByQueueName = $dependedOnBy->BaseObj->QueueObj->Name;
No it doesn’t find that matching Q_Name ( thats the issue ) . It find the Q_Name for the “child ticket” and stops after that.
A concrete exemple:
I have the “parent ticket” that is on queue “A” and a “child” ticket that is on queue “B” . The scrip on fist iterations, check for queue name “B” and then it stops and exit the while loop
my $dependedOnByQueueName = $dependedOnBy->TargetObj->QueueObj->Name;
returns “Q_Name” the scrip will bail. Which it sounds like “It find the Q_Name for the “child ticket” and stops after that.” thats what is happening right?
What I need is to get to this part of the script. To find The Q_Name for the “parent” ticket, not the “child” ticket, but right now, my script only checks for the Q_Name of the “child” ticket.
In other words, I need a method that will return all the DependsOn tickets for one ticket. And after that, I want to check if one of that DependOn ticket, is from a specific queue