Here's some code I use for doing the same type of thing:
set new value for CF Work-State
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $cf_name = “Work-State”;
my $cf_value = "Ready for Implementation;
$cf_obj->LoadByName( Name => $cf_name );
$RT::Logger->debug( “Loaded $cf_obj->Name = “. $cf_obj->Name() .”\n” );
$ticket->AddCustomFieldValue( Field=>$cf_obj, Value=>$cf_value,
I put that code in the Prep-Action area.
I put a "return 1;" in the clean-up action.
You will want to set the condition to "On Create".
You will want to set the action to "User-Defined".
Of course, you will want to change $cf_name and $cf_value to whatever.
Hope this helps.
LBNLOn 5/19/2009 9:48 AM, email@example.com wrote:
I am trying to figure out how to have a default value for a custom field.
I have defined a custom field called billable
it is a “select one value” field.
I added the options for n and y in that order.
How do I get the “n” to be the default option.
It always has no value when the ticket is first created.
I want it to be “n” unless someone changes it to "y"
Any pointers would be appreciated.
Thanks in advance.
Community help: http://wiki.bestpractical.com
Commercial support: firstname.lastname@example.org
Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com