Access Queue Name from ticket ID

Hello :slight_smile:

I am trying to get the queue name of a specific ticket from the ticket id.

my $prev_ticket_id = $self->TicketObj->id - $ticket_tracker;
my $checkTicketQueue =  $self->TicketObj->id - $ticket_tracker->Queue->Name;

the value of $ticket_tracker will be decreasing in a while loop until a condition is met

will
$self->TicketObj->id - $ticket_tracker->Queue->Name
provide me the name of the queue from the ticket id ?

Thank you for any feedback :slight_smile:

my $checkTicketQueue = $self->TicketObj->QueueObj->Name should work

If the ticket object is not the ticket you are interested in checking you need to load a new ticket object using which ever ID you have and then check the queue.

my $new_ticket = RT::Ticket->new( $session{'CurrentUser'} );
$new_ticket->Load( 1234 );
1 Like

I am trying to get the queue name from a ticket ID
for example:
Current ticket id : 100 ($self->TicketObj->id)
Current ticket id queue: queue1 ($self->TicketObj->id->Queue->Name)
previous ticket id : 99 ($self->TicketObj->id-1)
Current ticket id queue: queue2 ($self->TicketObj->id-1->Queue->Name)
previous ticket id : 98 ($self->TicketObj->id-2)
Current ticket id queue: queue1 ($self->TicketObj->id-2->Queue->Name)

Try $self->TicketObj->QueueObj->Name that will get you the QueueObj where you can then call the Name method on.

1 Like

can i get the queue name from the ticket id ?

can i get the queue name from the ticket id ?

No you need to load the RT::Ticket object from the ticket ID and then get the RT::Queue object from the newly loaded ticket object.

Below is an example of loading a ticket from ID 1234:

my $new_ticket = RT::Ticket->new( $session{'CurrentUser'} );
$new_ticket->Load( 1234 );
1 Like
my $prev_ticket_id =  $self->TicketObj->id - $ticket_tracker;
my $prev_ticket = RT::Ticket->new( RT->SystemUser );
$prev_ticket->Load( $prev_ticket_id );
my $prev_ticket_queue_name = $prev_ticket->Queue->Name;

Would you think this work?
The $ticket_tracker would be descending within a loop

Give it a try and test! But a quick look I’d say no. $prev_ticket->Queue->Name; In my example the method is “QueueObj” not “Queue”. I believe Queue just returns a queue ID.

The $ticket_tracker would be descending within a loop

You may want to also add some debug code to each line to see in the logs whats going on

1 Like

Yes yes, you’re right! :slight_smile: