[rt-users] Adding a CF with QuickCreate and index.html

alister at gossamer-threads.com alister at gossamer-threads.com
Thu Aug 26 00:16:59 EDT 2010



Hi rt-users,

I want to extend QuickCreate to adjust a CustomField on the homepage.

I was unable to add a CF easily in index.html with the CreateTicket()
command.
Here is what I did to get it working - I'm unsure if its the best way or
not.


After going through RT::Interface::Web::CreateTicket I came up with 
adding the following to Elements/CustomField

(anyone know an automated way to do this?)

    <input type="hidden" value="1"
name="Object-RT::Ticket--CustomField-1-Values-Magic" class="hidden">
    <select id="Object-RT::Ticket--CustomField-1-Values"
name="Object-RT::Ticket--CustomField-1-Values">
        <option selected="selected" value="">(no value)</option>
        <option >Canada</option>
        <option >Europe</option>
        <option >Global</option>
    </select>


Then in index.html I added 

        my ($t, $msg) = CreateTicket(
            Queue           => $ARGS{'Queue'},
            ...
+           'CustomField-1' =>
$ARGS{'Object-RT::Ticket--CustomField-1-Values'}
        );


This returned a RT::Ticket object (I was expecting an Id) and didn't add
the custom field value.
Since I had the ticket I added a bit more that I would normally put in a
scrip:

    if ($ticket && $ticket->Id) {
        unless ($ticket->FirstCustomFieldValue('Unit')) {
            my ($st, $msg) = $ticket->AddCustomFieldValue(
                Field => 'Unit',
                Value => $ARGS{'Object-RT::Ticket--CustomField-1-Values'},
                RecordTransaction => 0,
            );
            push @results, $msg;
        }
    }


It seems to me like CreateTicket was running RT::Ticket::Create instead of
RT::Ticket_Overlay::Create.

I think it might have been easier to create an Ticket/Create.html like
Element for the Dashboard.

Questions:

Should index.html run RT::Ticket or RT::Ticket_Overlay Create?
Has anyone got other suggestions for adding mandatory CF's in QuickCreate?



I am running:
RT-5.8.8 
Gentoo 
Apache-2.2 mod_perl
perl-5.10.1

Thanks in advance,









More information about the rt-users mailing list