[rt-users] Default value for custom fields
Ken Crocker
kfcrocker at lbl.gov
Tue Jun 2 12:56:17 EDT 2009
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
LBNL
On 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 at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090602/199aa529/attachment.htm>
More information about the rt-users
mailing list