Variable rtname not valid when executing rt-crontool

Hello,

We have set rtname in a RT_SiteConfig.pm to our company name. Everything works fine except when executing rt-crontool from crontab to for example send out a reminder of stalled tickets with a template as message. Then the subject has the string [example.com #123456] “” is stalled

Example:
/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --search-arg “Status = ‘stalled’ AND Due is NULL AND Told < ‘7 days ago’ AND Queue = ‘Support’ AND Owner != ‘Operations’” --action RT::Action::RecordComment --template ‘Stalled tickets’

Is RT_SiteConfig.pm not read when executing rt_crontool?

Regards,
Magnus

Then the subject has the string [example.com #123456] “” is stalled

The “example.com” Is the incorrect value?

Yes exactly, “example.com” is the default incorrect value. We want what we have set rtname to in RT_SiteConfig.pm.

And the name shows up correctly on the RT web UI, not as example.com?

Sorry for being unclear. It’s in emails the subjects are wrong, “example.com” not overridden with organisation name, when sent from crontab using rt-crontool. Correspondance sent from RT web UI gets the correct subject. It seems to us RT_SiteConfig.pm is not read when using rt-crontool for correspondance.

Okay, if you go to the ticket that rt-crontool forwarded on can you confirm that the ticket has a value for subject?

We don’t forward any ticket. We use a query (see thread start) and a template to create a comment in all tickets which have been stalled to long. The comment triggers an email to be sent to the ticket owner and to RT-Send-Cc. The subject of the sent email is prefixed with [example.com] though we have changed rtname in RT_SiteConfig.pm to mirror our organisation.

Example of template created in RT-Admin-Global-Templates:
Subject: “{$Ticket->Subject}” is stalled
RT-Send-Cc: cc@company.se

Hello,

Ticket {$Ticket->id} is stalled for seven days or more with no customer communication. Please consider to put the ticket in status pend_client.

Queue: {$Ticket->QueueObj->Name}
Subject: {$Ticket->Subject || “(No subject given)”}
Owner: {$Ticket->OwnerObj->Name}
Requestors: {$Ticket->RequestorAddresses}
Status: {$Ticket->Status}
Ticket URL: https://rt.company.se/Ticket/Display.html?id={$Ticket->id}

Regards,
RT Timed Notifications

Right, my mistake on the forward part. Does the ticket have a subject value? Or do you see “(No subject given)” for the body of the tickets where you see “[example.com #123456] “” is stalled” as the email subject header?

Yes, subject as specified in the template but prefixed with [example.com #ticket number].

Example from today:
[example.com #741632] “Company Portal: Documents are not working” is stalled

If the ticket that the crontool is sending the email out for doesn’t have a subject value then the header for the email subject here Subject: “{$Ticket->Subject}” is stalled will be empty quotes around the ticket subject, like you are saying you are seeing. You could change the code to this if you wanted to have a message saying no subject was provided:

Subject: “{$Ticket->Subject || '(No subject given)'}” is stalled

No. We have a subject in the ticket and it’s correct in the email sent out but it’s prefixed with [example. com] though we have configured rtname in RT_SiteConfig.pm to reflect our organisation.

In my example above “Company Portal: Documents are not working” is the subject but as you can see it has example.com as prefix. Example if rtname = company.se

Wrong
[example.com] #741632] “Company Portal: Documents are not working” is stalled

Correct
[company.se] #741632] “Company Portal: Documents are not working” is stalled

Two ideas:

a) Have you cleared the Mason cache and restarted the web server on the RT machine?

b) Do a recursive grep for “example.com” in the /opt/rt4/ hierarchy to see if it appears anywhere. For example if you have a /opt/rt4/local/etc/RT_SiteConfig.pm it will take precedence over /opt/rt4/etc/RT_SiteConfig.pm (assuming RT is built in /opt/rt4 obviously).

Hello,

Thank you for your reply.

a) Yes

b) I’ve done recursive grep earlier and investigated the result but will do it again.

Regards,
Magnus

Just a thought here: did the original tickets get created before you changed the settings to company.se?

Also check (as this has happened before) that you don’t have two Set($rtname, '....'); calls in your RT_SiteConfig.pm (easy to do by accident if you either have long config, or split it into separate files in a subdirectory).

Hello again,

We digged into this after seven months and it seems to me we now have solved the issue. The theory is that RT_SiteConfig.pm is not read when executing rt_crontool from crontab. Though it says in RT_Config.pm “NEVER EDIT RT_Config.pm” we changed $rtname and $Organization to mirror our setting in RT_SiteConfig.pm and now the subject for tickets are correct.

Thank you!

Regards,
Magnus