[rt-users] Custom Ticket Creation Form

Ruslan U. Zakirov cubic at acronis.ru
Tue Dec 16 06:52:58 EST 2003


Andy Harrison wrote:
>  I've created a custom form for ticket creation in a specific queue.  I wanted some specific information to be displayed and some related instructions, that sort of thing.  What I'd like is to make a link indicating "Description of Choices" which pops up a window displaying all of the clicked Custom Field's values and the description text of each possible value.  Could anyone help?
> 
>  I have not reinvented the wheel entirely, I used the original index.html and simply renamed it and put the modified version in the local directory tree, as well as modified versions of the EditCustomField and EditCustomFields elements.  Then I added a new section in the main menu sidebar to access it.  So all of the RT modules are available to my new form, I'm just not sure how to do it.
> 
>  John Schubert gave me a suggestion to use the alt= param, but that doesn't work well for me.
> 
>  I've added the following lines to the EditCustomFields element file:
> 
>          <script language="JavaScript" type="text/JavaScript">
>          <!--                                                
>            function MM_openBrWindow(theURL,winName,features) { //v2.0
>                    window.open(theURL,winName,features);            
>                     }                                  
>           //-->     
>           </script>
> 
>          [ <a href="#" onClick="MM_openBrWindow('Systems-Descriptions.html','test','width=  300,height=300')">Description of Choices</a> ]<br />
You can send arguments to your script 'Systems-Descriptions.html' with 
http GET method:
<a href="#" 
onClick="MM_openBrWindow('Systems-Descriptions.html?Key1=Value1&Key2=Value2','test','width=300,height=300')">
Description of Choices</a>
> 
> 
> 
>  Problem is, I'm not sure how to pass the current queue and such to that page.
> 
>  This doesn't even come close to working:
> 
>  Systems-Descriptions.html:
> 
>    %   print ":::", %ARGS, ":::\n";
>           <!-- start dumper -->
>           <p><hr width=100 align=left width=6><pre>
>    
>          <img src="<%$RT::WebImagesURL%>/gwi.jpg" alt= "
>    %#    print Dumper( $CustomField->Values() );
>    %     my $CustomFieldValues = $CustomField->Values();
>    %     while ( my $value = $CustomFieldValues->Next ) {
>    %         #print Dumper( $value->values->description );
>    %         print $value->{'values'}->{'description'},"\n" ;
This is rude hack and is not using of RT API. You are accessing class 
private data member which not described in public API.
>    %     }
>           ">
>    %#       </pre><hr width=100 align=left width=6></p>
>           <!-- end dumper -->
>    
>    %
>    <%INIT>
>    my $QueueObj = new RT::Queue($session{'CurrentUser'});
>    $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
>    my $CustomField = $QueueObj->CustomFields();
$QueueObj->CustomFields(); return collection of CustomField instances 
not one CustomField.

Try next code:
% my $CFs = $QueueObj->CustomFields();
% while (my $CF = $CFs->Next) {
%     my $CFVs = $CF->Values();
       <pre>CustomField: <% $CF->Name %>(<% $CF->Type %>)</pre><br>
       <pre>Description: <% $CF->Description %></pre><br>
       <pre>Values:</pre><br>
%     while ( my $CFV = $CFVs->Next ) {
          <pre>      Value: <% $CFV->Name %></pre><br>
          <pre>      Descr: <% $CFV->Description %></pre><br>
%     }
% }

>    </%INIT>
>    
>    <%ARGS>
>    $DependsOn => undef
>    $DependedOnBy => undef
>    $MemberOf => undef
>    $QuoteTransaction => undef
You don't need this ARGS.
>    $Queue => 35
You need only this ARG.
This(ARGS) section is described in Mason doc and allow magicaly bind 
request arguments to perl variables.
So now you can use $Queue or $ARGS{'Queue'} in your code. And pass them 
via URI: .../xxx.html?Queue=20
>    </%ARGS>
> 
>  This yields:
> 
>  error: 	Can't locate object method "Values" via package "RT::CustomFields" at /usr/local/rt3/local/html/Systems-Descriptions.html line 7.
RT::CustomFields class realy don't have method Values.
>  	
>  context: 	
>  ... 		
>  3: 	<p><hr width=100 align=left width=6><pre>	
>  4: 		
>  5: 	<img src="<%$RT::WebImagesURL%>/gwi.jpg" alt= "	
>  6: 	%# print Dumper( $CustomField->Values() );	
>  7: 	% my $CustomFieldValues = $CustomField->Values();	
>  8: 	% while ( my $value = $CustomFieldValues->Next ) {	
>  9: 	% #print Dumper( $value->values->description );	
>  10: 	% print $value->{'values'}->{'description'},"\n" ;	
>  11: 	% }	
>  ... 		
>  code stack: 	/usr/local/rt3/local/html/Systems-Descriptions.html:7
>  /usr/local/rt3/share/html/autohandler:182
> 




More information about the rt-users mailing list