[rt-users] Looking for correct place to put callback

Bart bart at pleh.info
Tue Mar 26 03:37:20 EDT 2013


2013/3/25 Raymond Corbett <Raymond.Corbett at arcproductions.com>

>  Stubborn I guess but I just keep refusing to give up. ****
>
> ** **
>
> Bart offered this solution to me:****
>
> ** **
>
> Basically, get his callback which adds the CF's to the ticket update page
> and add it to your callback which will get loaded for the quick create box.
> ****
>
> ** **
>
> The only thing I don't know is the name of the callback, but I think you
> could look in the code of the file you just created and search for callback
> and you'll get some names (I hope).****
>
> Otherwise check the wiki page I just linked, it has some info on finding
> what callback you need to use.****
>
> ** **
>
> Since it is the Quick Create portlet that I want to affect:****
>
> **·         **I looked into  rt4/local/html/Elements  and I found
> QuickCreate  which is the code that seems to populate the portlet with all
> the options****
>
> **·         **I found in this file                    %
> $m->callback(CallbackName => 'InFormElement');****
>
> ** **
>
> Therefore I assumed that I had to name my callback file   InFormElement
> so I did.****
>
> ** **
>
> My path is:****
>
>
> Rt4/local/html/Callbacks/InterfaceCallbacks/Elements/QuickCreate/InFormElement
> ****
>
> ** **
>
> But not go.    I notice the customizing with CallBacks doc talks of path
> to html-page.    There is a share/html/Ticket/Create.html****
>
> but this not the case with Quick Create.    It is not called
> QuickCreate.html****
>
> ** **
>
> Any suggestions to help me out. ****
>
> ** **
>
> ** **
>

Looks like you might have to hack this one :S

The callback you found is part of this line:

<form
    method="post"
    action="<%RT->Config->Get('WebPath')%>/index.html"
% $m->callback(CallbackName => 'InFormElement');
>

I've tried what you did, and regarding callbacks thats the right way of
using them, but it doesnt seem to work.
I assume that the above line adds the QuickCreate box as an element on the
index.html page using the callback InFromElement.

So the callback you've tried was one from the index.html page...

Hacking it is done this way (well, its another polite way of doing this):

mkdir -p /opt/rt4/local/html/Elements
cp /opt/rt4/share/html/Elements/QuickCreate /opt/rt4/local/html/Elements/

After that edit the title: (I'd also remove the big text of comments at the
start, it's only a small piece of code so it makes reading a little easier)

<&| /Widgets/TitleBox, title => loc('Quick ticket creation NEW') &>

And then restart the server:

service apache2 stop && rm -rf /opt/rt4/var/mason_data/obj/* && service
apache2 start

You've now replaced the "stock" quick create box with a new one, with your
own title (just so you see the difference).

After that you can try to add the custom fields, this is the code Ruslan
used so you could try to add it in the QuickCreate code (your own) and see
if it will do what you want it to: (2 callbacks)

*BeforeUpdate*
*
*
<%ARGS>
$TicketObj
$skip_update
$results
$ARGSRef => {}
</%ARGS>
<%INIT>
return unless $ARGSRef->{'SubmitTicket'};

my $CFs = $TicketObj->CustomFields;
my $ValidCFs = $m->comp(
    '/Elements/ValidateCustomFields',
    CustomFields => $CFs,
    NamePrefix => "Object-RT::Ticket-". $TicketObj->id ."-CustomField-",
    ARGSRef => $ARGSRef
);
unless ( $ValidCFs ) {
    $$skip_update = 1;
    while (my $CF = $CFs->Next) {
        my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
        push @$results, loc($CF->Name) . ': ' . $msg;
    }
}

*AfterWorked*
*
*
<& /Ticket/Elements/EditCustomFields,
    TicketObj => $Ticket,
    InTable => 1,
    DefaultsFromTopArguments => 0,
&>
<%ARGS>
$Ticket

This code hoever assumes a ticket is already in a certain queue, and then
gets the custom fields associated with it.
Since you're making a ticket, it's not yet in a queue, which makes it hard
to lookup which CF it "could" set.

So here you might have to take the piece of code inside the while loop and
manually define the CF's you want in there.

-- 
Bart G.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130326/51c6ca6a/attachment.htm>


More information about the rt-users mailing list