Postmaster regex

Moderator: crythias

Locked
gissberg
Znuny newbie
Posts: 4
Joined: 12 Dec 2013, 09:51
Znuny Version: 3.3.1
Real Name: Patrick Gissberg
Company: Fiberdata

Postmaster regex

Post by gissberg »

Hi,

I'm trying to get the external ticket ID from some of our customers and I'm stuck at one customers numbers. I've done the dynamic fields and got it to work with one customers internal ticket ID. I'll stop yaping and give you an example:

id#1737874485 Hastighetsproblem / 46785798 #1734434

The purple id is our ticket ID and the red one is the on I'm trying to Catch, I've tested the following regex:

(#[0-9]{7})\b
(?<!id#)(#[0-9]{7})\b

They both work fine when tested on this site http://www.perlfect.com/articles/regextutor.shtml but it doesn't work in OTRS. Is there any tool to test regex to see if it works in OTRS or can anyone here correct my faulty ones?

Cheers
OTRS 3.3.x Linux (Ubuntu) with PostgreSQL
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: Postmaster regex

Post by reneeb »

Can you post a screenshot of the postmaster filter?
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
gissberg
Znuny newbie
Posts: 4
Joined: 12 Dec 2013, 09:51
Znuny Version: 3.3.1
Real Name: Patrick Gissberg
Company: Fiberdata

Re: Postmaster regex

Post by gissberg »

Hello,

here's the screenshot.
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x Linux (Ubuntu) with PostgreSQL
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Postmaster regex

Post by crythias »

Your filter is three AND criteria, including searching for and insisting the ticket number is in the body
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
gissberg
Znuny newbie
Posts: 4
Joined: 12 Dec 2013, 09:51
Znuny Version: 3.3.1
Real Name: Patrick Gissberg
Company: Fiberdata

Re: Postmaster regex

Post by gissberg »

Aha, thanks alot. Editing the regex and make a new one to scan the body of the ticket.
OTRS 3.3.x Linux (Ubuntu) with PostgreSQL
gissberg
Znuny newbie
Posts: 4
Joined: 12 Dec 2013, 09:51
Znuny Version: 3.3.1
Real Name: Patrick Gissberg
Company: Fiberdata

Re: Postmaster regex

Post by gissberg »

Hey again, shouldn't the same regex work in PostMaster::PreFilterModule###000-ExternalTicketNumberRecognition1? I get the following error in apache-logs:

Code: Select all

Net::POP3=GLOB(0x2cd2fd8)>>> RETR 2
Net::POP3=GLOB(0x2cd2fd8)<<< +OK
Unmatched ( in regex; marked by <-- HERE in m/ (#[0-9]{7})\b  <-- HERE / at /opt/otrs/Kernel/System/PostMaster/Filter/ExternalTicketNumberRecognition.pm line 77.
Net::POP3=GLOB(0x2cd2fd8)>>> RSET
Net::POP3=GLOB(0x2cd2fd8)<<< +OK
Net::POP3=GLOB(0x2cd2fd8)>>> QUIT
Net::POP3=GLOB(0x2cd2fd8)<<< +OK Microsoft Exchange Server 2003 POP3 server version 6.5.7638.1 signing off.
If you haven't guessed it yet I really suck at regex :(
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x Linux (Ubuntu) with PostgreSQL
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Postmaster regex

Post by crythias »

dunno. I independently did one of these ... viewtopic.php?f=60&t=22681
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
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: Postmaster regex

Post by reneeb »

In the "ExternalTicketNumberRecognition" filter the Regex should look like

Code: Select all

(?<!id[#])([#][0-9]{7})\b
The module uses the x-modifier that allows to use comments (that starts with "#" in Perl) in regexes... In my opinion this is a bug that can be workaround by using a character class for the "#" - hence [#] in the regex.
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
ipguy
Znuny newbie
Posts: 40
Joined: 19 May 2010, 08:29
Znuny Version: 2.3.4

Re: Postmaster regex

Post by ipguy »

Hi gissberg

Did you manage to get this to work ?
I'm trying to do the same thing but I'm having a lot of problem setting it up, do we need to include the below in Config.pm ?

Code: Select all

    # Job Name: ExternalNumber
    # External Ticket Number Reconition, check for Incident-<number> in incoming mails subject and
    # body from the addeesses <sender>@externalticket.com, if number is found it will be stored in
    # the dynamic field 'ExternalNumber' (that need to be setup in the Admin Panel).
    $Self->{'PostMaster::PreFilterModule'}->{'000-ExternalTicketNumberRecognition5'} =  {
        'FromAddressRegExp' => '\\s*@externalticket.com',
        'NumberRegExp'      => 'Incident-(\\d.*)',
        'SearchInSubject'   => '1',
        'SearchInBody'      => '1',
        'TicketStateTypes'  => 'new;open'
        'DynamicFieldName'  => 'ExternalNumber',
        'Module'            => 'Kernel::System::PostMaster::Filter::ExternalTicketNumberRecognition',
        'Name'              => 'Test External Ticket Number',
        'SenderType'        => 'system',
    };


I can't get this to work no matter what I try.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Postmaster regex

Post by jojo »

this is done in the sysconfig. Do you use OTRS 3.3.?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ipguy
Znuny newbie
Posts: 40
Joined: 19 May 2010, 08:29
Znuny Version: 2.3.4

Re: Postmaster regex

Post by ipguy »

jojo wrote:this is done in the sysconfig. Do you use OTRS 3.3.?

yes, i have 3.3.7
do i need to do anything in "Core::PostMaster" or "PostMaster Filter Management"
If i drop this into Config.pm i keep getting a server error, so am obviously not doing something right... does it need to go in at the end after 1; or before, i've tried both ?
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Postmaster regex

Post by jojo »

check Core::Postmaster in sysconfig and alter settings there
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ipguy
Znuny newbie
Posts: 40
Joined: 19 May 2010, 08:29
Znuny Version: 2.3.4

Re: Postmaster regex

Post by ipguy »

sure, thats where i'm adding the setting but it's not working...
do you use this feature ?
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Postmaster regex

Post by jojo »

one of your regex might be wrong. Anything in the log?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

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