Reassigning ticket to other queue from a queue depending upon the custom field value

I want to reassign the ticket from the 1st queue to another 2nd queue depending upon the custom field value of 1st queue.

For ex : I have a custom field " additional hardware required". If it is set to “yes” in the 1st queue while creating ticket then it should automatically be moved to the 2nd queue.

Could anyone please let me know how to do this.

Hi ,
could anyone please help.

You need to create a new scrip in the first queue that has some custom code to look at the custom field value and then set the ticket queue based on that. This scrip will need to be fired off whenever you think the custom field may have been changed (so maybe use a condition of “On Transaction” if it could change on any transaction).

The $Ticket->FirstCustomFieldValue('additional hardware required') method call will get you the custom field value and $Ticket->SetQueue() methods are what you’ll need to look up the custom field value and then set the new queue for the ticket. You’ll probably also need to use an RT::Queue object to find the second queue and its ID if you don’t want to hard code it.

So $Ticket->FirstCustomFieldValue , it is the method to get the custom field value. Is it?
Where can I get all the details of these kind of functions $Ticket->SetQueue(), $Ticket->FirstCustomFieldValue and what are the different kind of functions exist in RT.

Is there any manual?

Yes - there’s a huge amount of online documentation - the Developer section gives you all the various objects and the public methods they provide. Be aware that RT::Ticket objects inherit from RT::Record, so you can use methods from RT::Record with RT::Ticket objects. Its normal object oriented stuff but worth pointing out if you’re wondering where methods like FirstCustomFieldValue() are in RT::Ticket.

Ohh Ok. That is agreta information. Thank you. Will keep posting if I face any more difficlties.
It seems these modules are in the path “RT installation directory/lib/RT”

Will the SetQueue() will take the Queue name as parameter.

Think that one is the queue ID

You might find the RT wiki documentation useful.

Can anybody please let me know that how I will get idea when I can use $self ,$TicketObj , $TicketPriority and if any other things are there.
How can I know like which modules or which functions I need to use for what purpose?

If I will give some print statement in custom code, how can I see the output? where it shall see the output.
I am trying to debug if the value is coming or not to the variable. could anyone please let me know how can I make sure the scrip which I have created is running fine or not.

You can use RT::Logger->error("Some message"); and RT::Logger->debug("Some warning"); to log to your RT logs

Hi I have created scrip . PFB the details. my customfield name: “Hardware require”. It is not reassigning the ticket to the destination queue while creating ticket with “Hardware require” as yes. COuld any please verify if i need to change anything.

Condition: On Create
Template : blank
Custom action preparation code:

Custom action commit code:

my $cf = “Hardware require”;
if ( $ticket->FirstCustomFieldValue($cf) =~ /Yes/)
$RT::Logger->warning("$cf exist for Queue “);
$RT::Logger->warning(”$cf doesn’t exist for Queue ");

I would log $ticket->FirstCustomFieldValue($cf) =~ /Yes/ and $ticket->FirstCustomFieldValue($cf) to first make sure the value is set to Yes, you may need to change the stage of to TransactionBatch as well.

I couldnot understand how to check $ticket->FirstCustomFieldValue($cf) is set to yes. How to check it’s value.

And how to change it to transaction batch . DO I need to recreate the scrip again. At the time of creation it shows stage as normal or batch.

You probably also want to use the queue Id, not its name, in the SetQueue() call.

except setting it to my queue id, anything else needs to be changed in my scrip , i posted above?

Well I’d do what Knation has suggested and log the value of the custom field whilst developing the scrip so that you can check what value it is acually appearing with and that you’re taking the right fork in the logical flow of the scrip.

So I need to add this below line to check in the RT logs the value of the custom field is coming yes or not.

$RT::Logger->warning(”$ticket->FirstCustomFieldValue($cf) ");
and the value will show in the main RT log file while creating a ticket right?Please correct me if I am wrong.

And where to change the transaction batch?