Implementing Automation to Set Custom Field Value Based on Ticket Title

Hello RTIR Community,

I’m looking to implement automation within RTIR to set the value of a custom field (CF.{7}) based on the title of a ticket. Specifically, I want the custom field to be set to a predefined value only when the exact phras is present in the ticket title.

I’ve tried implementing a Scrip in RTIR to achieve this functionality, but I’m encountering issues with getting it to work as expected. Here’s the Perl script I’ve attempted:

# This is an RTIR Scrip action code

# Get the current ticket object
my $ticket = $self->TicketObj;

# Get the CustomField object for CF.{7}
my $custom_field = $ticket->CustomFieldObj('CF.{7}');

# Get the title of the ticket
my $title = $ticket->Subject;

# Check if the exact phrase "Test Phrase" is contained in the title
if ($title =~ /\bTest Phrase\b/i) { # Case-insensitive match
    # Set the value of CF.{7} to 'CUSTOM FIELD VALUE'
    $ticket->AddCustomFieldValue(Field => $custom_field, Value => 'CUSTOM FIELD VALUE');
}

However, this script doesn’t seem to be setting the value of the custom field as expected.

Could anyone provide guidance on how to properly implement this automation within RTIR? Are there any alternative approaches or scripts that could achieve this functionality effectively?

Thank you in advance for your assistance!

When you say the custom field is CF.{7} do you mean it is the custom field with an ID of 7? In which case try using the line:

$ticket->AddCustomFieldValue(Field => 7, Value => 'CUSTOM FIELD VALUE');

Yes i mean that. I tried your solution, however it still doesn’t work. I also tried to put that istruction outside the if condition in order to set the parameter value for every ticket but it is not working. I set the script to run on creation of ticket, action defined by user and model correspondence. I also put the code in the section Custom action commit code. I am thinking maybe that the custom field value is not set correctly, i don’t know. What kind of tests could i make?

You could try replacing the ID number in AddCustomFieldValue with the name of the custom field. Is the custom field just a text field? Anything in the logs about errors?