[rt-users] CommandbyMail - CustomFields - Can't get $queue->TicketCustomFields;

Kevin Falcone falcone at bestpractical.com
Sat Jul 24 13:28:44 EDT 2010


On Thu, Jul 22, 2010 at 11:50:31PM -0400, anthony acquanita wrote:
>    So I never enter this while loop. If I run a script outside of RT it works

How do you know it is the same current user?
Compare $queue->CurrentUser->UserObj->Id to be sure

Generally this fails when a user doesn't have SeeQueue

-kevin

>    my $custom_fields = $queue->TicketCustomFields;
>    while ( my $cf = $custom_fields->Next ) {
>    $RT::Logger->error( "HORRAY" );
>    my %tmp = _ParseAdditiveCommand( \%cmds, 0, "CustomField{". $cf->Name ."}" );
>    next unless keys %tmp;
>    $create_args{ 'CustomField-' . $cf->id } = [ _CompileAdditiveForCreate(%tmp) ];
>    }
> 
>    ###############
>    perl script that works using same user
>    ###############
> 
>    use RT;
>    use RT::Queues;
>    use RT::Queue;
>    use RT::Interface::CLI qw(CleanEnv GetCurrentUser);
>    use RT::Tickets;
>    use Data::Dumper;
> 
>    RT::LoadConfig();
>    RT::Init();
>    my $current_user = GetCurrentUser('user' );
> 
>    #print Dumper $current_user;
>    my $queue = new RT::Queue($current_user);
>    my $queue_id = 15;
>    $queue->Load($queue_id);
>    my $custom_fields = $queue->TicketCustomFields;
>    #print Dumper $custom_fields;
> 
>    while ( my $cf = $custom_fields->Next ) {
>    print Dumper $cf;
>    }

> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100724/d2d587a0/attachment.sig>


More information about the rt-users mailing list