Setting dynamic field based on text in body [SOLVED]
Moderator: crythias
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Setting dynamic field based on text in body [SOLVED]
Hi,
Is the any way that we can interpret the body of an incoming ticket to set a Dynamic Field for the ticket.
For instance, if the customer writes in the body that the problem is located in a city called Stockholm, could you set our dynamic field "City" to Stockholm?
Regards
/Niklas
Is the any way that we can interpret the body of an incoming ticket to set a Dynamic Field for the ticket.
For instance, if the customer writes in the body that the problem is located in a city called Stockholm, could you set our dynamic field "City" to Stockholm?
Regards
/Niklas
Last edited by nickeswede on 02 Dec 2013, 01:17, edited 1 time in total.
-
- 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: Setting dynamic field based on text in body
If there are rules how the interesting parts can be identified, you can use a postmaster filter. If there are no rules, it is hard to determine what to store in the dynamic field...
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
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Re: Setting dynamic field based on text in body
Hi, and thanks for taking the time to answer this.
Yes, there are rules since the incoming mail are generated from a webform. Can we match it using regex?
/Niklas
Yes, there are rules since the incoming mail are generated from a webform. Can we match it using regex?
/Niklas
-
- 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: Setting dynamic field based on text in body
Yes... Select "Body" in the Match Header section and add the regex in the value field. In the Set-Header section, select X-OTRS-DynamicField-<NAME> and use "[***]" (without the quotes) in the value. That [***] is replaced with the matched string...
You might have to add your dynamic field as a valid header field in SysConfig (setting PostmasterX-Header in Group Ticket, Subgroup Core::Postmaster).
You might have to add your dynamic field as a valid header field in SysConfig (setting PostmasterX-Header in Group Ticket, Subgroup Core::Postmaster).
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
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Moderator
- Posts: 10170
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Setting dynamic field based on text in body
If generated from a web form, why not send the field as a header?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Re: Setting dynamic field based on text in body
Hi, thanks for your suggestion
We don't have control of the webforms and external ticketing systems that generates the incoming e-mails so I guess that is not an option.
All the best
/Niklas
We don't have control of the webforms and external ticketing systems that generates the incoming e-mails so I guess that is not an option.
All the best
/Niklas
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Re: Setting dynamic field based on text in body
Ok, I think we got the gist of it, but didn't quite get it to work, this is how we did:reneeb wrote:Yes... Select "Body" in the Match Header section and add the regex in the value field. In the Set-Header section, select X-OTRS-DynamicField-<NAME> and use "[***]" (without the quotes) in the value. That [***] is replaced with the matched string...
You might have to add your dynamic field as a valid header field in SysConfig (setting PostmasterX-Header in Group Ticket, Subgroup Core::Postmaster).
First we created a dynamic field (text) called postnr (zipcode in Swedish)
Then we created the filter:
Filter condition:
Header1: Body
Value: [1-9][0-9]{4}
Set email headers:
X-OTRS-DynamicField-postnr
Value: [***]
However, when we get a hit on the regex it sets the value to 1, see below:
TicketDynamicFieldUpdate Updated: FieldName=postnr;Value=1; - Admin OTRS 2013/11/29 15:00:07
Our goal is to get it to set the matched value
If we get a mail containing:
Niklas Andersson
Testvagen 1
11262 Stockholm
Sweden
We was hoping for this filter to set the value of the textfield to 11262, thereby being able to filter out and to get statistics on the zipcodes where we get tickets from.
Is it possible?
Regards
/Niklas
-
- 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: Setting dynamic field based on text in body
You need a capturing group, so (note the parens in the Value part)
should look likeFilter condition:
Header1: Body
Value: [1-9][0-9]{4}
Code: Select all
Filter condition:
Header1: Body
Value: ([1-9][0-9]{4})
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
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Re: Setting dynamic field based on text in body
Thanks alot! works like a charm.reneeb wrote:You need a capturing group, soshould look likeFilter condition:
Header1: Body
Value: [1-9][0-9]{4}(note the parens in the Value part)Code: Select all
Filter condition: Header1: Body Value: ([1-9][0-9]{4})
BTW, what happens it the regex finds/hits more than once? say that you get a ticket where the sender has his own zipcode in the signature? will it take the last one that if finds?
Said it before but I need to repeat it: thanks for taking the time to answer my questions!
/Niklas
-
- 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: Setting dynamic field based on text in body
It takes the first match...
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
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Znuny newbie
- Posts: 10
- Joined: 13 May 2013, 16:01
- Znuny Version: 3.2.3
- Real Name: Niklas Andersson
- Company: Fiberdata AB
Re: Setting dynamic field based on text in body
Got it to work properly.
Heres the regex if anyone may need it in the future:
\b([1-9]\d{2}\s*\d{2})\b
Triggers on Swedish zipcodes (not starting with zero):
All the best
/Niklas
Heres the regex if anyone may need it in the future:
\b([1-9]\d{2}\s*\d{2})\b
Triggers on Swedish zipcodes (not starting with zero):
All the best
/Niklas