CurrentUserEmail in search - better way instead copying Tickets_Local.pm

Hi,

I would like to create a search finding all my requested tickets
without using my hard-coded email-adr.

Therefore, I overlayed Tickets.pm with Tickets_Local.pm, removing the "use …"
and adding one line of code like described in http://requesttracker.wikia.com/wiki/CurrentUserEmail.

/opt/rt4/local/lib/RT/Tickets_Local.pm:2978
+ $value = $self->CurrentUser->EmailAddress if $value eq '__CurrentUserEmail__';

Now, it’s possible execute a search-query like
Requestor.EmailAddress = ‘CurrentUserEmail’ AND Status = ‘open’

Question: Is there a way not to copy the whole Tickets.pm but just
the relevant code snippet using callbacks/overaying/…

I tried to just copy _parser() method - but perl cannot find
variables from the base class Tickets.pm like FIELD_METADATA or %dispatch …

Is there a smoother way to implement this feature?

regards
Danny

smime.p7s (2.23 KB)

I would like to create a search finding all my requested tickets
without using my hard-coded email-adr.

Does
Requestor = 'CurrentUser
not work?

Therefore, I overlayed Tickets.pm with Tickets_Local.pm, removing the "use …"
and adding one line of code like described in http://requesttracker.wikia.com/wiki/CurrentUserEmail.

I can’t see how that code has ever been useful. Page should probably
be deleted.

Question: Is there a way not to copy the whole Tickets.pm but just
the relevant code snippet using callbacks/overaying/…

I tried to just copy _parser() method - but perl cannot find
variables from the base class Tickets.pm like FIELD_METADATA or %dispatch …

I suspect you failed to add package RT::Tickets; to the top of your
Tickets_Local.pm (those variables are marked our so should be fine to
use).

-kevin

Hi Kevin,

Does
Requestor = 'CurrentUser
not work?

Oh - yes, this works!! I didn’t know about this “Requestor” keyword. Great! Thank!

I tried to just copy _parser() method - but perl cannot find
variables from the base class Tickets.pm like FIELD_METADATA or %dispatch …

I suspect you failed to add package RT::Tickets; to the top of your
Tickets_Local.pm (those variables are marked our so should be fine to
use).

I added “package RT::Tickets” - but doesn’t matter. I will use your suggested solution!

Thanks
Danny

smime.p7s (2.23 KB)