How to include attachements to notifications

English! place to talk about OTRS development, programming and coding

Moderator: tto

Post Reply
HervE
OTRS superhero
Posts: 391
Joined: 03 Jan 2011, 17:15
OTRS Version?: 3.3.8
Location: France

How to include attachements to notifications

Post by HervE » 10 Oct 2011, 17:32

Hello,

As explained here, I needed to include attachements to notifications (event), even though it was not ArticleCreate event.

What I did:

I opened Kernel\System\Ticket\Event\NotificationEvent.pm.
I took the attachement block out of the "ArticleCreate" condition.
But...
$Param{Data}->{ArticleID} meant nothing. So I had to pick an Article object... which was done by function ArticleLastCustomerArticle().

Here is my new code:

Code: Select all

		# add attachments to notification
		# HvL - taken out of ArticleCreate event condition
		if ( $Notification{Data}->{ArticleAttachmentInclude}->[0] ) {
			# HvL - search for the article
			my %Article = $Self->{TicketObject}->ArticleLastCustomerArticle(
				TicketID => $Param{TicketID},
			);
		
			my %Index = $Self->{TicketObject}->ArticleAttachmentIndex(
				ArticleID                  => $Article{ArticleID},
				UserID                     => $Param{UserID},
				StripPlainBodyAsAttachment => 3,
			);
			if (%Index) {
				for my $FileID ( sort keys %Index ) {
					my %Attachment = $Self->{TicketObject}->ArticleAttachment(
						ArticleID => $Article{ArticleID},
						FileID    => $FileID,
						UserID    => $Param{UserID},
					);
					next if !%Attachment;
					push @Attachments, \%Attachment;
				}
			}
		}

		# send notification
Hope it may help anyone...

Regards,
HervE
OTRS 3.3.8 - Windows 7 - IIS7 - SQL Server - Firefox 30

tpsupport
OTRS expert
Posts: 52
Joined: 02 Feb 2011, 14:45
OTRS Version?: 6.0.8

Re: How to include attachements to notifications

Post by tpsupport » 24 Oct 2012, 14:32

Hi HervE,

Thank you very much for posting this article. This is exactly what I was searching for! Unfortunately it does not seem to work for me. I am using OTRS 3.1.10 at the moment, maybe they changed the code somewhere and that disabled the workaround. I checked the part "# add attachments to notification" in the NotificationEvent.pm against the older version from OTRS 3.0.6 and the code matched.

How can I achieve attachment forwarding with the event "TicketCreate" in this version?
I would appreciate any feedback as this is currently a show stopper.

Thank you in advance!

Rick
OTRS 6 - Ubuntu 16.04 x64, Azure Database for MySQL server 5.7, Perl 5.22.1, Apache/2.4.18

tpsupport
OTRS expert
Posts: 52
Joined: 02 Feb 2011, 14:45
OTRS Version?: 6.0.8

Re: How to include attachements to notifications

Post by tpsupport » 25 Oct 2012, 09:50

I found another interesting code patch on osdir.com. The author shows how to patch Ticket.xml. Article.pm and NewTicket.pm to support attachment forwarding on new ticket notification for agents. This solution would work for me, too. Unfortunately this also seems to need an update for the current OTRS version as this caused my OTRS installation to stop processing new emails.

Subject: Patch: Forward email attachments with new ticket
http://osdir.com/ml/otrs.devel/2008-06/msg00014.html
OTRS 6 - Ubuntu 16.04 x64, Azure Database for MySQL server 5.7, Perl 5.22.1, Apache/2.4.18

jojo
Moderator
Posts: 14289
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to include attachements to notifications

Post by jojo » 25 Oct 2012, 10:46

use notification event for this
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

tpsupport
OTRS expert
Posts: 52
Joined: 02 Feb 2011, 14:45
OTRS Version?: 6.0.8

Re: How to include attachements to notifications

Post by tpsupport » 25 Oct 2012, 11:43

Hi jojo,

As already stated by HervE "... I needed to include attachments to notifications (event), even though it was not ArticleCreate event."which is exactly what I need. With the event "TicketCreate" you cannot forward email attachments.


Regards, Rick
OTRS 6 - Ubuntu 16.04 x64, Azure Database for MySQL server 5.7, Perl 5.22.1, Apache/2.4.18

jojo
Moderator
Posts: 14289
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to include attachements to notifications

Post by jojo » 25 Oct 2012, 12:01

then use article create
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

tpsupport
OTRS expert
Posts: 52
Joined: 02 Feb 2011, 14:45
OTRS Version?: 6.0.8

Re: How to include attachements to notifications

Post by tpsupport » 25 Oct 2012, 12:44

Hi jojo,

I am sorry but "ArticleCreate" is not an option for what I am going to do. I need "TicketCreate" to send the initial request to a bug tracking system with attachment, the other system replies with an own tracking number in subject if an employee acknowledges receipt. If someone would write to the otrs ticket again (e.g. via web front end) it would result in a new bug report if the bug tracking number is not in subject. Thats why I configured another event notification based on "ArticleCreate" which will only forward the notification if e.g. DynamicField_X is set to "1". The DynamicField value is set to "1" as soon as the bug tracking system replied with a bug tracking number (configured through postmaster filter). This whole thing works great but I need the attachment in first mail to be forwarded as well. If I set the first notification event to "ArticleCreate" as well then this event will forward not only the initial but also all other emails even without a bug tracking number.

I hope this helps to understand why it is important that it works for TicketCreate event. As already stated I would also be happy with an new ticket agent notification modification.


Rick
OTRS 6 - Ubuntu 16.04 x64, Azure Database for MySQL server 5.7, Perl 5.22.1, Apache/2.4.18

jojo
Moderator
Posts: 14289
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: How to include attachements to notifications

Post by jojo » 25 Oct 2012, 12:54

what about custom development or enhancement of the framework?
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

tpsupport
OTRS expert
Posts: 52
Joined: 02 Feb 2011, 14:45
OTRS Version?: 6.0.8

Re: How to include attachements to notifications

Post by tpsupport » 25 Oct 2012, 13:48

Hi jojo,

Unfortunately my company does not pay for any OTRS enhancements. I am not an administrator so I am doing OTRS stuff only if there is a free slot. As all the rest of this works I will have to inform customers to send attachments in their next email as only the initial mail is set to TicketCreate event.

Thanks for your comment.
OTRS 6 - Ubuntu 16.04 x64, Azure Database for MySQL server 5.7, Perl 5.22.1, Apache/2.4.18

DBSRAJW
OTRS newbie
Posts: 23
Joined: 25 Jul 2014, 15:39
OTRS Version?: 3.3.12

Re: How to include attachements to notifications

Post by DBSRAJW » 02 Oct 2014, 08:38

You can create an Event Based notification via "Notifications (Event)" in admin menu and then setting the option "Include attachments to notification" to "Yes". This will simply include the attachments into the notification.
OTRS version: 3.3.12
Operating System: VM / Debian7
Database type: MySQL

RodrigoPetter
OTRS expert
Posts: 51
Joined: 10 Aug 2015, 20:02
OTRS Version?: 5.0.0

Re: How to include attachements to notifications

Post by RodrigoPetter » 07 Jul 2017, 22:51

Don't know if this still a problem to some one else, but the HervE code will only send attachments that was related to de last customer answer.

In my case, I wanted to get the attachments from the last article, from an agent or customer.

So I did the follow:
csi.jpg
This way, it always will have a value in the parameter $Param{Data}->{ArticleID} and the notification will be able to get the attachments from the last answer.

OBS: Max function came from "use List::Util 'max';"
You do not have the required permissions to view the files attached to this post.

Post Reply