Setting values with single quotes to CF's

In a commit code block I’ve wrote this:

my ( $status, $msg ) = $self->TicketObj->AddCustomFieldValue(
    Field => $CFName,
    Value => $CFValue,
    RecordTransaction => 1 );
$RT::Logger->error("Couldn’t set $CFValue: $msg") unless $status;

If $CFValue is:

  • “Santiago de Compostela” → there is no problem.
  • “Barcelona’s beach” → AddCustomFieldValue throws “Invalid value for custom field ((eval 3029):149)”

I’ve tried different approaches but only the inverted tick works (`) but it doesn’t look good and leads to other post processing problems (that’s not the expected character).

Any clue where to dig?

That is a select-values CF, to be throwing that error with text values? And assuming both values are configured as allowed values on the CF. Your apostrophe in the post is U+2019 (right single quotation mark) but you probably intended to send in U+0027 (apostrophe/ascii).

You’re right, @zkelly. It’s a select-values CF (I forgot to specify this).

To clarify also the encoding I’ll write again both examples.

"Santiago de Compostela" -> OK
"Barcelona's beach" -> NOT OK (apostrophe)
"Barcelona`s beach" -> OK (left quotation mark)

OMG! Stupid by copy/paste… the apostrophe was not really an apostrophe… after rewriting all the values by hand… it woks OK.