[rt-users] custom field question

Ken Crocker kfcrocker at lbl.gov
Tue May 19 13:55:19 EDT 2009


Prescott,


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

return 1;

    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.

Kenn
LBNL

On 5/19/2009 9:48 AM, prescott at wcoil.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.
>
>
>
> _______________________________________________
> 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
>
>   



More information about the rt-users mailing list