Set CustomField from scrip action

Okay, I’m doing something wrong, and I’m just getting over a bad cold so
my brain isn’t all here. I’m trying to set a CustomField value from
within a scrip. I’ve watched the debug output and the scrip is run, but
the CustomField value is still null. CF is named ‘createdbyemail’, set
as a select one value type, with a possible value of ‘yes’. Scrip
action:

my $cf = RT::CustomField->new( $RT::SystemUser );
$cf->LoadByName( Name => ‘createdbyemail’ );
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => ‘yes’ );
return 1;

I can’t even remember how I got started with this particular chunk of
code (I’m pretty sure I stole it from something in the contributed
scrips area of the wiki)…help would be appreciated. Thanks!

On Wed, 08 Apr 2009 17:36:08 -0700, “Nick Kartsioukas”
change+lists.rt@nightwind.net said:

my $cf = RT::CustomField->new( $RT::SystemUser );
$cf->LoadByName( Name => ‘createdbyemail’ );
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => ‘yes’ );
return 1;

Got it. Should be double-quotes instead of single-quotes for the value
to set, so:
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => “yes” );

Nick,

Try changing your code to add the custom field value like this:

$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => ‘yes’, RecordTransaction=>0 );

Also, make sure the values you are using are correct in terms of 

case. “Yes” is not the same as “yes” and if the values you allow for the
CF has “Yes” and NOT “yes”, then it won’t work. Same for the CF name.

Hope this helps.

Kenn
LBNLOn 4/8/2009 5:36 PM, Nick Kartsioukas wrote:

Okay, I’m doing something wrong, and I’m just getting over a bad cold so
my brain isn’t all here. I’m trying to set a CustomField value from
within a scrip. I’ve watched the debug output and the scrip is run, but
the CustomField value is still null. CF is named ‘createdbyemail’, set
as a select one value type, with a possible value of ‘yes’. Scrip
action:

my $cf = RT::CustomField->new( $RT::SystemUser );
$cf->LoadByName( Name => ‘createdbyemail’ );
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => ‘yes’ );
return 1;

I can’t even remember how I got started with this particular chunk of
code (I’m pretty sure I stole it from something in the contributed
scrips area of the wiki)…help would be appreciated. Thanks!


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

On Wed, 08 Apr 2009 17:36:08 -0700, “Nick Kartsioukas”
change+lists.rt@nightwind.net said:

my $cf = RT::CustomField->new( $RT::SystemUser );
$cf->LoadByName( Name => ‘createdbyemail’ );
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value =>
‘yes’ );
return 1;

Got it. Should be double-quotes instead of single-quotes for the
value
to set, so:
$self->TicketObj->AddCustomFieldValue( Field => $cf, Value => “yes” );

Single vs double quotes in that context shouldn’t make any difference…

Tim

The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.