[rt-users] Default value for custom fields

Matthew Seaman matthew.seaman at thebunker.net
Tue Jun 2 14:05:02 EDT 2009


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090602/e879c43b/attachment.sig>


More information about the rt-users mailing list