2013/3/25 Raymond Corbett <span dir="ltr"><<a href="mailto:Raymond.Corbett@arcproductions.com" target="_blank">Raymond.Corbett@arcproductions.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Stubborn I guess but I just keep refusing to give up. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Bart offered this solution to me:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="color:red">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.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="color:red"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:red">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).<u></u><u></u></span></p>

<p class="MsoNormal"><span style="color:red">Otherwise check the wiki page I just linked, it has some info on finding what callback you need to use.<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Since it is the Quick Create portlet that I want to affect:<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><u></u>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<u></u><u></u></p>
<p><u></u><span style="font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><u></u>I found in this file                    % $m->callback(CallbackName => 'InFormElement');<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Therefore I assumed that I had to name my callback file   InFormElement   so I did.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My path is:<u></u><u></u></p>
<p class="MsoNormal">Rt4/local/html/Callbacks/InterfaceCallbacks/Elements/QuickCreate/InFormElement<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">But not go.    I notice the customizing with CallBacks doc talks of path to html-page.    There is a share/html/Ticket/Create.html<u></u><u></u></p>
<p class="MsoNormal">but this not the case with Quick Create.    It is not called QuickCreate.html<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Any suggestions to help me out. <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>

</blockquote></div><br>Looks like you might have to hack this one :S<div><br></div><div>The callback you found is part of this line:</div><div><br></div><div><div><font face="courier new, monospace"><form</font></div>
<div><font face="courier new, monospace">    method="post"</font></div><div><font face="courier new, monospace">    action="<%RT->Config->Get('WebPath')%>/index.html"</font></div><div>
<font face="courier new, monospace">% $m->callback(CallbackName => 'InFormElement');</font></div><div><font face="courier new, monospace">></font></div></div><div><br></div><div>I've tried what you did, and regarding callbacks thats the right way of using them, but it doesnt seem to work.</div>
<div>I assume that the above line adds the QuickCreate box as an element on the index.html page using the callback InFromElement.</div><div><br></div><div>So the callback you've tried was one from the index.html page...</div>
<div><br></div><div>Hacking it is done this way (well, its another polite way of doing this):</div><div><br></div><div>mkdir -p /opt/rt4/local/html/Elements</div><div>cp /opt/rt4/share/html/Elements/QuickCreate /opt/rt4/local/html/Elements/</div>
<div><br></div><div>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)</div><div><br></div><div><font face="courier new, monospace"><&| /Widgets/TitleBox, title => loc('Quick ticket creation NEW') &></font></div>
<div><br></div><div>And then restart the server:</div><div><br></div><div><font face="courier new, monospace">service apache2 stop && rm -rf /opt/rt4/var/mason_data/obj/* && service apache2 start</font></div>
<div><br></div><div>You've now replaced the "stock" quick create box with a new one, with your own title (just so you see the difference).</div><div><br></div><div>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)</div>
<div><br></div><div><b>BeforeUpdate</b></div><div><b><br></b></div><div><div><font face="courier new, monospace"><%ARGS></font></div><div><font face="courier new, monospace">$TicketObj</font></div><div><font face="courier new, monospace">$skip_update</font></div>
<div><font face="courier new, monospace">$results</font></div><div><font face="courier new, monospace">$ARGSRef => {}</font></div><div><font face="courier new, monospace"></%ARGS></font></div><div><font face="courier new, monospace"><%INIT></font></div>
<div><font face="courier new, monospace">return unless $ARGSRef->{'SubmitTicket'};</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">my $CFs = $TicketObj->CustomFields;</font></div>
<div><font face="courier new, monospace">my $ValidCFs = $m->comp(</font></div><div><font face="courier new, monospace">    '/Elements/ValidateCustomFields',</font></div><div><font face="courier new, monospace">    CustomFields => $CFs,</font></div>
<div><font face="courier new, monospace">    NamePrefix => "Object-RT::Ticket-". $TicketObj->id ."-CustomField-",</font></div><div><font face="courier new, monospace">    ARGSRef => $ARGSRef</font></div>
<div><font face="courier new, monospace">);</font></div><div><font face="courier new, monospace">unless ( $ValidCFs ) {</font></div><div><font face="courier new, monospace">    $$skip_update = 1;</font></div><div><font face="courier new, monospace">    while (my $CF = $CFs->Next) {</font></div>
<div><font face="courier new, monospace">        my $msg = $m->notes('InvalidField-' . $CF->Id) or next;</font></div><div><font face="courier new, monospace">        push @$results, loc($CF->Name) . ': ' . $msg;</font></div>
<div><font face="courier new, monospace">    }</font></div><div><font face="courier new, monospace">}</font></div></div><div><div><br></div><div><b><font face="arial, helvetica, sans-serif">AfterWorked</font></b></div><div>
<font face="courier new, monospace"><b><br></b></font></div><div><div><font face="courier new, monospace"><& /Ticket/Elements/EditCustomFields,</font></div><div><font face="courier new, monospace">    TicketObj => $Ticket,</font></div>
<div><font face="courier new, monospace">    InTable => 1,</font></div><div><font face="courier new, monospace">    DefaultsFromTopArguments => 0,</font></div><div><font face="courier new, monospace">&></font></div>
<div><font face="courier new, monospace"><%ARGS></font></div><div><font face="courier new, monospace">$Ticket</font></div></div><div><br></div><div>This code hoever assumes a ticket is already in a certain queue, and then gets the custom fields associated with it.</div>
<div>Since you're making a ticket, it's not yet in a queue, which makes it hard to lookup which CF it "could" set.</div><div><br></div><div>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.</div>
<div><br></div>-- <br>Bart G.
</div>