[rt-users] External CustomFieldValues : Users from certain groups

Kriegers Horst Horst.Kriegers at loro.ch
Thu May 1 08:02:17 EDT 2014


Hi List,


I try to have only the users from certain groups in a custom field.
My code doesn’t work. I need your help.
Removing the “WhoBelongToGroups” is OK, no error ans all users are available.

RT version : 4.2.0


Thanks in advances.
Horst


local/lib/RT/CustomFieldValues/ADIUsers.pm
=========================================================================
package RT::CustomFieldValues::ADIUsers;

use strict;
use warnings;

use base qw(RT::CustomFieldValues::External);

sub SourceDescription {
    return 'RT LoRo ADI users';
}

sub ExternalValues {
    my $self = shift;

    my @res;
    my $i = 0;
    my $users = RT::Users->new( $self->CurrentUser );
    $users->LimitToPrivileged;
    $users->WhoBelongToGroups{ Groups => {40}, IncludeSubgroupMembers => 0 };
    $users->LimitToEnabled;

    while( my $user = $users->Next ) {
        push @res, {
            name        => $user->Name.' ('.$user->RealName.')',
            description => $user->RealName,
            sortorder   => $i++,
        };
    }
    return \@res;
}


RT::Base->_ImportOverlays();

1;
==========================================================================



error log contains :
-----------------------
[17114] [Thu May  1 11:56:08 2014] [error]: syntax error at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 99, near "->WhoBelongToGroups{ "
Global symbol "$users" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 101.
Global symbol "$users" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 104.
Global symbol "@res" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 105.
Global symbol "$i" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 108.
Global symbol "@res" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 111.
syntax error at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 112, near "}"
Compilation failed in require at (eval 791) line 2.

Stack:
  [(eval 791):2]
  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:161]
  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:54]
  [/opt/rt4/share/html/Elements/EditCustomField:99]
  [/opt/rt4/share/html/Elements/EditCustomFields:65]
  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:56]
  [/opt/rt4/share/html/Widgets/TitleBox:56]
  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:57]
  [/opt/rt4/share/html/Ticket/Modify.html:66]
  [/opt/rt4/share/html/Ticket/autohandler:66]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:680]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:368]
  [/opt/rt4/local/html/autohandler:55]

Stack:
  [/opt/rt4/sbin/../lib/RT/CustomField.pm:489]
  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:161]
  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:54]
  [/opt/rt4/share/html/Elements/EditCustomField:99]
  [/opt/rt4/share/html/Elements/EditCustomFields:65]
  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:56]
  [/opt/rt4/share/html/Widgets/TitleBox:56]
  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:57]
  [/opt/rt4/share/html/Ticket/Modify.html:66]
  [/opt/rt4/share/html/Ticket/autohandler:66]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:680]
  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:368]
  [/opt/rt4/local/html/autohandler:55] (/opt/rt4/sbin/../lib/RT/Interface/Web/Handler.pm:211)
Trace begun at /opt/rt4/sbin/../lib/RT.pm line 295
Log::Dispatch::__ANON__('Log::Dispatch=HASH(0x7fa4358d1470)', 'syntax error at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 99, near "->WhoBelongToGroups{ "^JGlobal symbol "$users" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 101.^JGlobal symbol "$users" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 104.^JGlobal symbol "@res" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 105.^JGlobal symbol "$i" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 108.^JGlobal symbol "@res" requires explicit package name at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 111.^Jsyntax error at /opt/rt4/sbin/../local/lib/RT/CustomFieldValues/ADIUsers.pm line 112, near "}"^JCompilation failed in require at (eval 791) line 2.^J^JStack:^J  [(eval 791):2]^J  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:161]^J  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:54]^J  [/opt/rt4/share/html/Elements/EditCustomField:99]^J  [/opt/rt4/share/html/Elements/EditCustomFields:65]^J  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:56]^J  [/opt/rt4/share/html/Widgets/TitleBox:56]^J  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:57]^J  [/opt/rt4/share/html/Ticket/Modify.html:66]^J  [/opt/rt4/share/html/Ticket/autohandler:66]^J  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:680]^J  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:368]^J  [/opt/rt4/local/html/autohandler:55]^J^JStack:^J  [/opt/rt4/sbin/../lib/RT/CustomField.pm:489]^J  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:161]^J  [/opt/rt4/local/html/Elements/EditCustomFieldSelect:54]^J  [/opt/rt4/share/html/Elements/EditCustomField:99]^J  [/opt/rt4/share/html/Elements/EditCustomFields:65]^J  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:56]^J  [/opt/rt4/share/html/Widgets/TitleBox:56]^J  [/opt/rt4/share/html/Elements/EditCustomFieldCustomGroupings:57]^J  [/opt/rt4/share/html/Ticket/Modify.html:66]^J  [/opt/rt4/share/html/Ticket/autohandler:66]^J  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:680]^J  [/opt/rt4/sbin/../lib/RT/Interface/Web.pm:368]^J  [/opt/rt4/local/html/autohandler:55]^J') called at /opt/rt4/sbin/../lib/RT/Interface/Web/Handler.pm line 211
HTML::Mason::Exception::as_rt_error('HTML::Mason::Exception=HASH(0x7fa43a4693e8)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/Exceptions.pm line 282
HTML::Mason::Exception::as_string('HTML::Mason::Exception=HASH(0x7fa43a4693e8)', undef, '') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/Request.pm line 570
HTML::Mason::Request::_handle_error('RT::Interface::Web::Request=HASH(0x7fa439c93e18)', 'HTML::Mason::Exception=HASH(0x7fa43a4693e8)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/Request.pm line 521
HTML::Mason::Request::exec('RT::Interface::Web::Request=HASH(0x7fa439c93e18)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/PSGIHandler.pm line 96
eval {...} at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/PSGIHandler.pm line 96
HTML::Mason::Request::PSGI::exec('RT::Interface::Web::Request=HASH(0x7fa439c93e18)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/Interp.pm line 345
HTML::Mason::Interp::exec(undef, undef, 'id', 71439) called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/PSGIHandler.pm line 59
eval {...} at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/PSGIHandler.pm line 59
HTML::Mason::PSGIHandler::invoke_mason('HTML::Mason::PSGIHandler::Streamy=HASH(0x7fa439c944d8)', 'HASH(0x7fa439710878)', 'HASH(0x7fa433513760)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/HTML/Mason/PSGIHandler/Streamy.pm line 52
HTML::Mason::PSGIHandler::Streamy::__ANON__('CODE(0x7fa439f15778)') called at /opt/rt4/sbin/../lib/RT/Interface/Web/Handler.pm line 307
RT::Interface::Web::Handler::__ANON__('CODE(0x7fa439f15778)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/Plack/Util.pm line 301
Plack::Util::__ANON__('CODE(0x7fa439e88fe0)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/Plack/Handler/Apache2.pm line 89
Plack::Handler::Apache2::call_app('Plack::Handler::Apache2', 'Apache2::RequestRec=SCALAR(0x7fa431f70f50)', 'CODE(0x7fa439e2b0f8)') called at /opt/perl-5.18.1/lib/site_perl/5.18.1/Plack/Handler/Apache2.pm line 126
Plack::Handler::Apache2::handler('Apache2::RequestRec=SCALAR(0x7fa431f70f50)') called at -e line 0
eval {...} at -e line 0






________________________________
Note Importante: Le contenu de ce courriel est uniquement réservé à la personne ou l'organisme à qui il est destiné. Si vous n'êtes pas le destinataire prévu, veuillez nous en informer au plus vite et détruire le présent courriel. Dans ce cas, il ne vous est pas permis de copier ce courriel, de le distribuer ou de l'utiliser de quelque manière que ce soit.

________________________________
Important Notice: The content of this e-mail is intended only and solely for the use of the named recipient or organization. If you are not the named recipient, please inform us immediately and delete the present e-mail. In this case, you are not allowed to copy, distribute or use this e-mail in any way.

________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140501/a771855b/attachment.htm>


More information about the rt-users mailing list