[rt-users] Getting CurrentUser reference in Users overlay file

aniket tripathy aniket.tripathy at gmail.com
Fri Jun 24 04:14:14 EDT 2016


My bad, in the above script, the $self was holding the 1st argument, rather
than the reference of RT::Users class.

The original subroutine returns the ref of RT::Users.
As per the documentation of Hook::Lexwrap, the returned value from the
original subroutine should be accessible from the post subroutine using
$_[-1].

When I access $_[-1], using print or warn, I get the warning
* [warning]: Use of uninitialized value $_[-1] in concatenation (.) or
string*

Users_Local.pm
-----------------------
package RT::Users;
use strict;
use Hook::LexWrap;
wrap 'SimpleSearch' =>
        post=> sub {
        RT::Logger->info("accessing return value here $_[-1]");
        RT::Logger->info("I got the arguments in post: [@_]");
},
;
1;

Can anybody please help how will I be able to fetch the value returned by
the original subroutine ?
Thanks.



On Tue, Jun 21, 2016 at 1:05 PM, aniket tripathy <aniket.tripathy at gmail.com>
wrote:

> Hi,
>
> I intend to filter the results returned by SimpleSearch method in Users.pm
> based on the custom field value set in the current user logged in.
>
> I am using Hook::LexWrap in the Users_Local.pm overlay file, to write a
> post method to filter the results of SimpleSearch. How can I get a ref of
> CurrentUser which in turn will help to fetch the custom field value on that
> user?
>
> I tried using
> my $user = $self->CurrentUser;
>
> But getting the following error:
> [error]: Can't locate object method "CurrentUser" via package "Privileged"
> (perhaps you forgot to load "Privileged"?)
>
> Can anybody suggest what am I doing wrong here?
>
> Thanks in Advance.
>
> -Aniket
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20160624/353dd108/attachment.htm>


More information about the rt-users mailing list