"Invalid value for custom field"

I am attempting to populate a previously created CustomField (“Assigned_Group”) for a ticket with the group name, which is created in a different script from the domain name from the requestor’s email address. (I’m repeating the process of pulling the domain name here, but at some point I’ll circle back and pull it from the group name that’s been created). I’m unable to determine why I’m getting the error “Invalid value for custom field” as a return in my scrip.

# Custom Scrip action to populate a custom field with the group name
my $ticket = $self->TicketObj;

# Get the requestor's email address
my $requestor_email = $ticket->RequestorAddresses;

# Extract domain from email address
my ($domain) = $requestor_email =~ /\@(.+)$/;

# Create group name based on the domain
my $group_name = "Group_$domain";

# Get the custom field name
my $custom_field = $ticket->QueueObj->CustomField('Assigned_Group');

# Update custom field value with the group name
my ($st, $msg ) = $ticket->AddCustomFieldValue(Field => $custom_field, Value => $group_name);
$RT::Logger->debug("CUSTOM FIELD: Status: $st Msg: $msg");
return 1;

EDIT- One additional thought- I’ve tried a few different permutations of this script, including changing the Value field to a simple string like Value => 'TestValue' and I still get the same error, so it’s not like it’s rejecting it because the variable points to like a hashed value or something.

I think you might want just the custom field name or id in the Field parameter, rather than an object.

Hey it’s you again! You’re my dang hero. Thanks for helping me on my last Perl debacle.

So like this, right?
my ($st, $msg ) = $ticket->AddCustomFieldValue(Field => 'Assigned_Group', Value => $group_name);

I got the same error in syslog using this code. I even tried making the both the field and the value into strings and got the same error.

my ($st, $msg ) = $ticket->AddCustomFieldValue(Field => 'Assigned_Group', Value => 'TestValue');

@GreenJimll Do you happen to know if there a doc page that goes into the details for the AddCustomFieldValue method? I swear I’ve seen a page that lists all the methods for everything out in like 4 columns of links, but all I’ve been able to find recently is something like this page, which doesn’t drill down into specifics.

Do you happen to know if there a doc page that goes into the details for the AddCustomFieldValue method?

Nevermind, found it finally. RT 5.0.5 Documentation - Best Practical

Fixed. I’ve been talking to RT support. The syntax was right, but I had to change the custom field type from ‘select one value’ to ‘enter one value’. Now it works great.

1 Like