Set CustomField value on 'Quick ticket creation'

Hi all,

Is it possible to set the value of a global custom field by using the
’Quick ticket creation’ form?

I’ve modified the form to show that custom field but I found the custom
field is not updated while the ticket is created.

Below is contents of my ‘/Elements/QuickCreate’:

<& /Elements/TitleBoxStart, title => loc(‘Quick ticket creation’) &>

<&|/l&><% $CF->Name %>:
<& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "Object-RT::Transaction--CustomField-" &>
<&|/l&>Subject:
<&|/l&>Queue:
<& /Elements/SelectQueue, Name => 'Queue', ShowNullOption => 0, ShowAllQueues => 0 &>
<& /Elements/TitleBoxEnd &>

<%init>
my $CF = RT::CustomField->new( $session{‘CurrentUser’});
$CF->LoadByName(Queue => 0, Name => ‘Area’);
</%init>

Any idea?

Regards,
Stephen

Hello!On Mon, 2006-02-06 at 17:58 +0800, Stephen Fung wrote:

Is it possible to set the value of a global custom field by using the
‘Quick ticket creation’ form?

I’ve modified the form to show that custom field but I found the custom
field is not updated while the ticket is created.

I’d toss those modifications and make a scrip (either global or for that
queue only) which on ticket creation (OnCreate) uses the user-defined
bits to set the proper value. You can access the Custom Field from
within the TicketObj like so:

my $cf_name = ‘My Custom Field’;
my $default_value = ‘Foo’;

my $queue_obj = $self->TicketObj->QueueObj;
my $cf_obj = RT::CustomField->new($queue_obj->CurrentUser);
$cf_obj->LoadByNameAndQueue(Name => $cf_name,
Queue => $queue_obj->id);
unless( $cf_obj->id ) {
$RT::Logger->warning("$cf_name doesn’t exist for Queue ".
$queue_obj->Name);
return undef;
}

Get the first CF value for this ticket/field combo

my $cf_val = $self->TicketObj->FirstCustomFieldValue($cf_obj->id);

Set the CF value

my($st, $msg) =
$self->TicketObj->AddCustomFieldValue(
Field => $cf_obj->id,
Value => $default_value,
RecordTransaction =>1
);

Credit for this bit of code goes to my cohort, Russell Dumornay, who
puzzled out what was needed to do this trick.

Cheers!

–j
Jim Meyer, Geek at Large purp@acm.org