Fill dynamic fields with email body and subject

Moderator: crythias

Locked
Dethas
Znuny newbie
Posts: 25
Joined: 18 Jan 2017, 12:27
Znuny Version: 6.0.8
Real Name: Patric

Fill dynamic fields with email body and subject

Post by Dethas »

Hello,
i have been fighting with this for a couple of days, i can't find solution to that.
The case is that when i receive an email with specific Subject(to this moment i got everything right) i wanto to populate my two dynamic fields with subject of this email and body of this email, and i just don't know how to do it correctly. I need this two dynamic field to be filled to make sure my process work right. Is there any way in OTRS standard functions to do it?
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: Fill dynamic fields with email body and subject

Post by reneeb »

There are three ways:

1) Create two postmaster filters:

a) Filter: Subject -> (.*?(?:your subject filter).*)
Set: X-OTRS-DynamicField_SubjectField -> [***]
b) Filter: Subject -> (?:your subject filter)
Body -> (.*)
Set: X-OTRS-DynamicField_BodyField -> [***]

2) Use http://opar.perl-services.de/dist/Enhan ... lter-5.0.2

The Postmaster filter looks like this then:

a) Filter: Subject -> (?<subject>.*?(?:your subject filter).*)
Body -> (?<body>.*)
Set: X-OTRS-DynamicField_SubjectField -> [**\subject**]
X-OTRS-DynamicField_BodyField -> [**\body**]

3) Write your own postmaster filte rmodule


(The actual regexes might differ from the shown regexes as I haven't tested those)
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
Dethas
Znuny newbie
Posts: 25
Joined: 18 Jan 2017, 12:27
Znuny Version: 6.0.8
Real Name: Patric

Re: Fill dynamic fields with email body and subject

Post by Dethas »

Hey!
Thank you very much for your help, i almost got it right.
There is one thing to be done now.
I want to match entire text of en email body, but now with (.*) i match only one line of
that text. How can i match multiple lines of text? I tried to find solution, but i couldn't find anything usefull.
Is there a way to get whole text of a body? Or i just missing something from you previous post?
Dethas
Znuny newbie
Posts: 25
Joined: 18 Jan 2017, 12:27
Znuny Version: 6.0.8
Real Name: Patric

Re: Fill dynamic fields with email body and subject

Post by Dethas »

Ok, i got it!
I have found a solution on stackoverflow :)
Regex is ((.|\n)*) and it matches whole text of email body.
Thank you for your help, thanks to you i know some basics of how regex work :)
Locked