[rt-users] Custom Ticket Creation Form

Ruslan U. Zakirov cubic at acronis.ru
Mon Dec 15 13:11:05 EST 2003


Andy Harrison wrote:
[snip]
> 
>  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" ;
>    %     }
>           ">
>    %#       </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();
>    </%INIT>
>    
>    <%ARGS>
>    $DependsOn => undef
>    $DependedOnBy => undef
>    $MemberOf => undef
>    $QuoteTransaction => undef
>    $Queue => 35
>    </%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.
>  	
>  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
> 
		Hello.
First of all, people don't like read huge texts on MLs.
For API docs use something like this:
perldoc /www/rt3/lib/RT/CustomField_Overlay.pm

Watch errors more careful.
There is realy no method 'Values' in 'RT::CustomFields', but it's in 
'RT::CustomField'.

A little about RT API:
1) *_Overlay.pm, *_Vendor.pm and *_Local.pm it's includes in (*).pm with 
same namespace as (*).pm. This files contains extension and override 
funcs and includes at (*).pm loadtime. Order of including could be found 
  at the end of (*).pm I skip them below, this modules don't have own 
namespace.
2) RT<->DB interactions based on DBIx::SearchBuilder.
RT::Handle - ISA DBIx::SearchBuilder::Handle::YourDBType;
RT::SearchBuilder - ISA DBIx::SearchBuilder, RT::Base;
RT::Record - ISA RT::Base, DBIx::SearchBuilder::Record;

3) RT::Base - is superclass that provide CurrentUser, loc methods for 
children.

4) Table - it's collection of records. So there pairs of classes for 
each table with some exceptions as usually:

ACE.pm				ACL.pm
Attachment.pm 			Attachments.pm
CachedGroupMember.pm		CachedGroupMembers.pm
CustomField.pm			CustomFields.pm
CustomFieldValue.pm		CustomFieldValues.pm
GroupMember.pm			GroupMembers.pm
Group.pm			Groups.pm
Link.pm				Links.pm
Principal.pm			Principals.pm
Queue.pm			Queues.pm
ScripAction.pm			ScripActions.pm
ScripCondition.pm		ScripConditions.pm
Scrip.pm			Scrips.pm
Template.pm			Templates.pm
TicketCustomFieldValue.pm	TicketCustomFieldValues.pm
Ticket.pm			Tickets.pm
Transaction.pm			Transactions.pm
User.pm				Users.pm

Left column ISA RT:Record, right ISA RT::SearchBuilder subclasses.
Right are collections of left. So you can Limit* them, Count and 
move(First, Next, Prev, Last) through them. Allmost all functions 
derived from DBIx::SearchBuilder except Limit* and some other, they are 
defined in *_Overlay.pm

When you move through collection, functions return Record instance 
inherited from RT::Record which represents row in table.
Table fields could be accessed in to ways:
1) $record->FieldName - get value of 'FieldName'
2) $record->SetFieldName - set value of 'FieldName'
This was achieved with perl AUTOLOAD mechanism.
This classes also often have different Load* funcs, it's useful when you 
  want to Load particular row in instance by some parametr(field, eg Name)

Tables can have relationships with other tables, for such cases classes 
derived from RT::Record has special methods which return another RT::* 
instances, eg:
RT::Ticket has method OwnerObj(defined in RT/Ticket_Overlay.pm) that 
return new RT::User instance already Loaded with Ticket's owner, but 
Transactions sub returns collection.

5) There is also 'exception' classes in RT:
URI.pm
System.pm
Date.pm
CurrentUser.pm

		I hope this help you a little. Ruslan.




More information about the rt-users mailing list