Send email reminder fails with undefined value

I am having issues when using rt-crontool to send emails

/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --search-arg ‘(Status
= “open” or Status = “new”)’
–action RT::Action::SendEmail --action-arg Owner --transaction first
–template ‘Recordatorio’)

Error:
Template parsing error: Can’t call method “Id” on an undefined value at
template line 3

The template contains:

Revisar el ticket #{$Target->Id} y resolver de ser posible.

{RT->Config->Get(‘WebURL’)}Ticket/Display.html?id={$Target->Id}

I understand the error, it doesn’t like $Target->Id, i guess it isn’t
available at that moment, but that template is basically the same "Reminder"
template that comes with RT. How do i fix this?

I basically want to send automatic emails to owners when they have
unresolved tickets.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805.html

Hi List,
not sure if this is a bug or if I’m to stupid.

Following Setup.

Default Lifecycle: new, open, stalled, rejected, resolved, deleted
Special Lifecycle: new, open, development, testing, accepted, rejected, resolved, deleted

Queue Setup:
Lifecycle: Special Lifecycle

Queue Rights:
Group: Queue Members Full Access (SeeQueue, ShowTicket(Comments), ModifyTicket, OwnTicket etc.)
Role: AdminCcs: Also Full Access (SeeQueue, ShowTicket(Comments), ModifyTicket, OwnTicket etc.)

Now, if a user of the Queue Members Full Access Group opens the Ticket, he can change the Status for this lifecycle, but if a AdminCC opens the Ticket, he only gets the Status from Default Lifecycle, even with same rights like the Full Access Members

Is this a bug, or wrong configuration from my side?!?

Any Help appreciated

Torsten

Kühne + Nagel (AG & Co.) KG
Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE 812773878.
Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Reiner Heiken (Vors.), Dirk Blesius, Martin Brinkmann, Holger Ketz, Jan-Hendrik Köstergarten, Christian Marnetté, Christian Solf, Jens Wollesen.
Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt.
Geschäftsleitung Region Westeuropa: Yngve Ruud (Vors.), Hans-Georg Brinkmann (Stellv.), Richard Huhn, Björn Johansson, Bruno Mang, Stefan Paul, Tim Scharwath, Dominic Edmonds, Peder Winther.

Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen Spediteursbedingungen (ADSp), jeweils neuester Fassung. Wir verweisen insbesondere auf die vom Gesetz abweichenden Haftungsbeschränkungen von Ziffer 23 und 24 ADSp. Den vollständigen Text der ADSp übersenden wir Ihnen gerne auf Anfrage und können Sie auch unter http://www.kuehne-nagel.com einsehen. Ergänzend wird vereinbart, dass (1) Ziffer 27 ADSp im Rahmen internationaler Übereinkommen weder unsere Haftung noch die Zurechnung des Verschuldens von Leuten und sonstigen Dritten zu Gunsten des Auftraggebers erweitert, und (2) wir in den im deutschen Seehandelsrecht aufgeführten Fällen des nautischen Verschuldens oder Feuer an Bord nur für eigenes Verschulden und (3) im Sinne der CMNI genannten Voraussetzungen nicht für nautisches Verschulden, Feuer an Bord oder Mängel des Schiffes haften.

If i change --action RT::Action::SendMail to --action
RT::Action::RecordComment then the template gets ignored and a scrip gets
called that uses its own template and then i get mail.

However i don’t want to record a comment, i just want mail to get sent,
otherwise the tickets will get swamped with comments.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58807.html

Another change, with another module:

i changed rt-crontool to:

/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --search-arg “Queue =
‘apoyo’ AND Owner != ‘Nobody’ AND ( Status = ‘open’ OR Status = ‘new’
) AND Created < ‘1 day ago’” --action RT::Action::Notify --action-arg
’Owner’ --template ‘Recordatorio’

And now i get this error:

Oct 14 11:01:03 mar-zabbix RT: [8035] Can’t call method “CreatorObj” on an
undefined value at /opt/rt4/bin/…/lib/RT/Action/SendEmail.pm line 957.

I went to the code and found this:
unless ( $friendly_name ) {
$friendly_name = $self->TransactionObj->CreatorObj->FriendlyName;

So i went and added --transaction last to cron and ran again and i don’t get
an error, but no email is sent, with this message in the logs:

[9114] [Tue Oct 14 15:44:03 2014] [info]:
+rt-4.2.8-9114-1413301443-1484.5-0-0@mar-zabbix.seguroscatatumbo.com
#5/9797 -
+Scrip #rule (/opt/rt4/bin/…/lib/RT/Action/SendEmail.pm:284)
[9114] [Tue Oct 14 15:44:03 2014] [info]:
+rt-4.2.8-9114-1413301443-1484.5-0-0@mar-zabbix.seguroscatatumbo.com No
+recipients found. Not sending.
(/opt/rt4/bin/…/lib/RT/Interface/Email.pm:378)

I even added a To:{$Ticket->Owner} in the template and i still get the same
message. What i am missing? The documentation to the modules doesn’t give
examples. Not even if i put my email in the --action-arg will work.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58809.html

I had to put this on the template:

Otherwise no email would get sent.

However, i would think a better approach is to not have to hardcode the
owner to the template and pass it as a argument to rt-crontool so i can
reuse the template and have other cron jobs notify other users such as the
admincc or someone else.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58810.html

Revisar el ticket #{$Target->Id} y resolver de ser posible.

{RT->Config->Get(‘WebURL’)}Ticket/Display.html?id={$Target->Id}

I understand the error, it doesn’t like $Target->Id, i guess it isn’t
available at that moment, but that template is basically the same "Reminder"
template that comes with RT. How do i fix this?

Except that it’s not the same, the RT template creates $Target

This reminder is for ticket #{$Target = $Ticket->RefersTo->First->TargetObj;$Target->Id}.

I basically want to send automatic emails to owners when they have
unresolved tickets.

You want an RT::Action::Notify and to pass the Owner and NotifyActor
arguments, an example of this is in the reminders documnetation

https://bestpractical.com/docs/rt/latest/reminders.html

I suspect that your other failures are related to the Owner being the
last person to update the ticket and running into problems with the
NotifyActor setting.

You should not specify To: in the template if you want RT to calculate
a recipient.

-kevin

My guess is that my problem was the NotifyActor setting as you say because i
had already tried the example on the Reminders documentation but without
that setting.

The NotifyActor documentation says that RT doesn’t notify the person that
does an update, however IMHO cron should be exempted by default since you
don’t usually run cron jobs in response of events (aren’t scrips for that?).
No biggie since the example shows how to overrule this.

Kevin Falcone-2 wrote

Except that it’s not the same, the RT template creates $Target

This reminder is for ticket #{$Target =
$Ticket->RefersTo->First->TargetObj;$Target->Id}.

You want an RT::Action::Notify and to pass the Owner and NotifyActor
arguments, an example of this is in the reminders documnetation

I suspect that your other failures are related to the Owner being the
last person to update the ticket and running into problems with the
NotifyActor setting.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58819.html

Kevin Falcone-2 wrote

This reminder is for ticket #{$Target =
$Ticket->RefersTo->First->TargetObj;$Target->Id}.

BTW i still get Template parsing error: Can’t call method “TargetObj” on an
undefined value at template line 3 with that example so i am keeping just
Ticket->Id to make it work.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58820.html

Kevin Falcone-2 wrote

This reminder is for ticket #{$Target =
$Ticket->RefersTo->First->TargetObj;$Target->Id}.

BTW i still get Template parsing error: Can’t call method “TargetObj” on an
undefined value at template line 3 with that example so i am keeping just
Ticket->Id to make it work.

The template is intended to be used on Reminders, which always have a
RefersTo linked ticket. I assume your ticket does not have such a
link.

-kevin

The NotifyActor documentation says that RT doesn’t notify the person that
does an update, however IMHO cron should be exempted by default since you
don’t usually run cron jobs in response of events (aren’t scrips for that?).
No biggie since the example shows how to overrule this.

You’re using Scrip conditions and actions to implement your cron, so
if you want their behavior to be different, you need to tell them that
(they don’t know or care how they’re being accessed and adding more
logic doesn’t seem sensible).

-kevin

I am finding that RT::Action::Notify is recording onto the history of the
ticket. Is there a way to remove this?

I am getting “root (RT) - Outgoing email recorded” entries everywhere.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58823.html

I found the thread on the list
http://requesttracker.8502.n7.nabble.com/Suppressing-RT-System-itself-entries-in-Ticket-History-td52865.html
that explains that a method to suppress these kind of elements in the ticket
history is to code a callback where you can skip some transactions.

What would be the name of the transaction i need to skip? I only want to
suppress outgoing emails done by the root user itself (i have another super
user - myself, and i don’t want to skip from that)

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58838.html

Le 15/10/2014 14:20, fleon a �crit :

I found the thread on the list
http://requesttracker.8502.n7.nabble.com/Suppressing-RT-System-itself-entries-in-Ticket-History-td52865.html
that explains that a method to suppress these kind of elements in the ticket
history is to code a callback where you can skip some transactions.

What would be the name of the transaction i need to skip? I only want to
suppress outgoing emails done by the root user itself (i have another super
user - myself, and i don’t want to skip from that)

here is a part of what I use here. I Hide most day to day useless
transaction in ticket display page, thought I allow to see all when
clicking on History link. You should find what you wan’t in this sample
code :slight_smile:

local/html/Callbacks/YourOrg/Elements/ShowHistory/SkipTransaction:

<%init>

Hide systems transaction (except comments/corresponds) in history by

default
$$skip = 1 if ( ( $r->uri && $r->uri !~ /History.html/ )
&& ( ( $Transaction->Type && $Transaction->Type =~
m/^(EmailRecord|CommentEmailRecord|CustomField)$/ )
|| ( $Transaction->Field && $Transaction->Field =~
m/^(Owner|Status|Queue|EeCustomer)$/ )
) );
</%init>
<%args>
$Transaction => undef
$skip => undef
</%args>

Easter-eggs Sp�cialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - M�tro Gait�
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

I am having issues making your example work.
I created
/opt/rt4/local/html/MyCallbacks//Elements/ShowHistory/SkipTransaction and it
contains the following:

I restarted the webserver ,assigned permissions to the web user and deleted
the mason cache. I don’t see any changes on either screen, my guess is that
the new code isn’t even launching
How RT knows that it will look for the SkipTransaction file if i created a
new dir “MyCallbacks”

I would prefer RT::Action::Notify to not mess with the ticket altogether.
How is people doing if using cron?

Emmanuel Lacour wrote

local/html/Callbacks/YourOrg/Elements/ShowHistory/SkipTransaction:

<%init>

Hide systems transaction (except comments/corresponds) in history by

default
$$skip = 1 if ( ( $r->uri && $r->uri !~ /History.html/ )
&& ( ( $Transaction->Type && $Transaction->Type =~
m/^(EmailRecord|CommentEmailRecord|CustomField)$/ )
|| ( $Transaction->Field && $Transaction->Field =~
m/^(Owner|Status|Queue|EeCustomer)$/ )
) );
</%init>
<%args>
$Transaction => undef
$skip => undef
</%args>

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58847.html

Le 15/10/2014 20:38, fleon a �crit :

I am having issues making your example work.
I created
/opt/rt4/local/html/MyCallbacks//Elements/ShowHistory/SkipTransaction and it
contains the following:

Wrong path, it must be:

/opt/rt4/local/html/Callbacks/Whatever/Elements/ShowHistory/SkipTransaction

Easter-eggs Sp�cialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - M�tro Gait�
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

Sorry, i mistyped.

The code is definitely executing, because i put a
RT->Logger->error($Transaction->Type); at the beginning of the code. But i
get all transactions shown on the main ticket view!

I even did just a return; on the code to see it exit and it shows the same.

Here is all the output shown in the ticket page:

It’s the “Outgoing email recorded” messages i would like to not even
generate on the database. If that isn’t possible, at least hide the messages
when the emails are generated by a cron job instead of regular user input to
the ticket. Or put in another way, i want to hide every email that gets sent
from root.

Here’s the output i get on syslog when printing the transaction user and
type:

User 12 seems to be root, and EmailRecord is the transaction
Can’t i use RT::Action:SendEmail instead of RT::Action::Notify to avoid
getting the transaction on the ticket in the first place? That way i could
delete the callback…But i would need SendEmail to be able to read the
ticket information

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58856.html

I made the code work! I got suspicious when i saw that emails from cron came
from user root, id =12. 12??? Isn’t the superuser supposed to be id 1?

So i hardcoded 12 into the line:
return unless $Transaction->Creator == 12;

And now it hides those transactions.

I tried substituting the cron job with SendEmail:

51 7 * * * root /opt/rt4/bin/rt-crontool --search RT::Search::FromSQL
–search-arg
"Queue = ‘apoyo’ AND Owner != ‘Nobody’ AND ( Status = ‘open’ OR Status =
‘new’ )
AND Created < ‘1 day ago’" --action RT::Action::SendEmail --action-arg
Owner,Alwa
ysNotifyActor --template ‘Recordatorio’ --transaction first

But on syslog i get a notice that it doesn’t have recipients therefore mail
won’t get sent.

View this message in context: http://requesttracker.8502.n7.nabble.com/Send-email-reminder-fails-with-undefined-value-tp58805p58857.html

Can’t i use RT::Action:SendEmail instead of RT::Action::Notify to avoid
getting the transaction on the ticket in the first place? That way i could
delete the callback…But i would need SendEmail to be able to read the
ticket information

Using SendEmail is significantly more complicated, you can’t just pass
it the arguments consumed by Notify and hope it works. It takes
totally different arguments and you will need to do significantly more
work to configure the recipients.

-kevin