Default value for custom fields

I may be being thick here, but I can’t see a way to do this from the web
interface. If I create a custom field of ‘Select One Value’ type, is
there any way of making one of the values selected by default? The
actual application I’m looking at here is for tracking time spent
working on tickets out of normal business hours, for which we would
charge extra. The vast majority of work will be done during normal
hours, so I’d like that to be the default value.

Cheers,

Matthew

Dr Matthew Seaman The Bunker, Ash Radar Station
PGP: 0x60AE908C on servers Marshborough Rd
Tel: +44 1304 814890 Sandwich
Fax: +44 1304 814899 Kent, CT13 0PL, UK

signature.asc (259 Bytes)

Matthew,

Try creating a scrip that has the condition of "OnCreate", an action 

as “user-Defined” and put code in the prep action code area that sets
the CF to the value you want (see below). Put “return 1;” in the
clean-up action area. That should do it.

Prep Action code:

set the CF Work-Completed Date

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $cf_name = “Work-Completed Date”;
my ( undef, undef, undef, $mon, $day, $year ) = localtime( time );
my $cf_value = sprintf( ‘%d/%02d/%02d’, $year + 1900, $mon, $day );

$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,
RecordTransaction=>0);

return 1;

Kenn
LBNLOn 6/2/2009 1:41 AM, Matthew Seaman wrote:

I may be being thick here, but I can’t see a way to do this from the web
interface. If I create a custom field of ‘Select One Value’ type, is
there any way of making one of the values selected by default? The
actual application I’m looking at here is for tracking time spent
working on tickets out of normal business hours, for which we would
charge extra. The vast majority of work will be done during normal
hours, so I’d like that to be the default value.

Cheers,

Matthew



http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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

Ken Crocker wrote:

Matthew,

Try creating a scrip that has the condition of “OnCreate”, an action
as “user-Defined” and put code in the prep action code area that sets
the CF to the value you want (see below). Put “return 1;” in the
clean-up action area. That should do it.

Prep Action code:

set the CF Work-Completed Date

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;
my $cf_obj = RT::CustomField->new($RT::SystemUser);
my $cf_name = “Work-Completed Date”;
my ( undef, undef, undef, $mon, $day, $year ) = localtime( time );
my $cf_value = sprintf( ‘%d/%02d/%02d’, $year + 1900, $mon, $day );

$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,
RecordTransaction=>0);

return 1;

Hmmm… Thanks. I’d pretty much already come to the conclusion a bit
of scriping (if that’s the appropriate gerund) would be necessary.

Cheers,

Matthew

Dr Matthew Seaman The Bunker, Ash Radar Station
PGP: 0x60AE908C on servers Marshborough Rd
Tel: +44 1304 814890 Sandwich
Fax: +44 1304 814899 Kent, CT13 0PL, UK

signature.asc (259 Bytes)