SQL Query - Add email field of queue that received ticket

Moderator: crythias

Post Reply
amdkryn
Znuny expert
Posts: 187
Joined: 02 Oct 2012, 02:52
Znuny Version: 5.0.27

SQL Query - Add email field of queue that received ticket

Post by amdkryn »

Hi,

How do I add the following query the information on which the e-mail was used to record the ticket?

I have two email accounts registered in the system receiving the tickets from customers, for example, teste@empresa.com, chamado@empresa.com, but the query does not display them.

SELECT ticket.tn, tht.name ticket_history FROM `left join` th ticket on ticket.id = th.ticket_id left join ticket_history_type tht on tht.id = th.history_type_id WHERE th.history_type_id in (12);

The goal is to know which email gets more tickets, as each email is related to a queue. Or what was the queue that received the emails.

Thank you,
Last edited by crythias on 18 Jul 2014, 14:44, edited 1 time in total.
Reason: title change ou to of because OU means something else.
OTRS version 5.0.27 (With ITSM), Operating System OpenSuse 12 with Mysql.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: SQL Query - Add email field ou queue that received ticke

Post by reneeb »

This is not possible with a plain SQL query. The address the mail was sent to is in the article table, but this not just the plain mail address, but can have the "realname" or "comments", too (in fact, anything that is RFC compliant). But if the mails are dispatched to the queues based on the TO address, you could create a statistic where the ticket was created in the specific queues - and you have to check the article_type/sender_type.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
amdkryn
Znuny expert
Posts: 187
Joined: 02 Oct 2012, 02:52
Znuny Version: 5.0.27

Re: SQL Query - Add email field ou queue that received ticke

Post by amdkryn »

The emails are not sent to the queues based on the destination address. I use IMAP to push the direct emails to the corresponding queue.
OTRS version 5.0.27 (With ITSM), Operating System OpenSuse 12 with Mysql.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: SQL Query - Add email field ou queue that received ticke

Post by reneeb »

amdkryn wrote:The emails are not sent to the queues based on the destination address. I use IMAP to push the direct emails to the corresponding queue.
Can you explain that?

I assume: You have created an Email-Address entry (Admin -> Email-Adresses) for both mail adresses, and you said the settings where the mails to this address to which queue they should go to.

This is what I meant with "Dispatching based on the TO address". This has nothing to do with receiving the mails. You could have two mail accounts or only one - that doesn't matter. When OTRS creates new tickets from mails, it looks at the TO address, searches for an Email-Address entry and if one is found, the ticket is created in the queue that is set in the address settings.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
amdkryn
Znuny expert
Posts: 187
Joined: 02 Oct 2012, 02:52
Znuny Version: 5.0.27

Re: SQL Query - Add email field of queue that received ticke

Post by amdkryn »

I configured in "Admin -> PostMaster Mail Accounts" which define the target queue.

Referring to "have to check the article_type / sender_type" tried to create a report but did not have that option. Refers to consult via SQL?
OTRS version 5.0.27 (With ITSM), Operating System OpenSuse 12 with Mysql.
Post Reply