Insert CustomFieldValues into Subject

Hello everybody,

we are trying to use a script, which puts the input of two CustomFields into the subject. We already found a way to manage it, but it only works with one CustomField:

here is the custom preparation code:
return 0 unless (!$self->TicketObj->Subject);
return 1;

custom cleanup code:
my $subject1 = $self->TicketObj->FirstCustomFieldValue(‘Choose_subject_here’);
my $subject2 = $self->TicketObj->FirstCustomFieldValue(‘Choose_subject_here’);


return 1;

If we create a new variable and try to concat both, it only uses one. Do we use the wrong Method(FirstCustomFieldValue) or do we need to concat the variables in a special way?


Unless I’m mis-reading/mis-understanding, you’re getting the value from the same custom field and putting it into $subject1 and $subject2 variables. If you have two custom fields, I’d have expected to see to different names in the FirstCustomFieldValue() parameter.

1 Like

It’s a different field, I forgott to change the name (copy/paste :roll_eyes:).

my $subject1 = $self->TicketObj->FirstCustomFieldValue(‘First’);
my $subject2 = $self->TicketObj->FirstCustomFieldValue(‘Second’);

In the script-code the identifiers from subject1/2 are differnt, so it wasn’t the problem.

So if you do something like:

$self->TicketObj->SetSubject("$subject1 / $subject2");

instead of your two calls to SetSubject, what do you get?

1 Like

It creates two objects with hashvalues:

RT::ObjectCustomFieldValuee=HASH(0x00000) / RT::ObjectCustomFieldValuee=HASH(0x00000)

Seem like it can’t convert the two CustomFields?

my $subject1 = $self->TicketObj->FirstCustomFieldValue(‘Choose_subject_here’);
my $subject2 = $self->TicketObj->FirstCustomFieldValue(‘Choose_subject_here’);
$self->TicketObj->SetSubject("$subject1 $subject2");

1 Like

Creates the same output without Slash (/).

What about:

my $subject1 = $self->TicketObj->FirstCustomFieldValue(‘First’)->Content;
my $subject2 = $self->TicketObj->FirstCustomFieldValue(‘Second')->Content;
$self->TicketObj->SetSubject("$subject1 $subject2");
1 Like

Not working. I don’t get it, seems so simple to concat two Strings.
Thanks for all the replies!

We had another problem with our variables and fixed it.
Now its working. Thank you all :slightly_smiling_face: