Regular Expression is not working in Event Rule Transformation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 09:39 AM
Hello Community!
This has been driving me crazy the past hour or so.
I am trying to write a Regex that will match the name of a server from the corresponding event description. The Regex should match the first word in parenthesis BEFORE the '\' character.
I have a Regex that tests fine in the Regex101 tester configured according to ServiceNow's KB article:
But no matter what I do, I cannot for the life of me get the Regex to match anything in the event rule designer:
Can anyone see what I am doing wrong here?
Thanks in advance for your assistance!
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2024 11:02 PM
Hi @Rob M1
From the screenshot, I can see that the regex has been changed to \((.*)\\.** from \((.*)\\.* as per the error message. Can you please check on it once ? Also, validate on the description field whether the input string for regex validation is in the right format.
The regex for event rules is a bit more sensitive than that and the entire string has to be captured or it would only parse correctly if the entire beginning of the string was exactly the same each time. The Xplore regex tester unfortunately does not use the same backend regex as event management rules (nor does regex101 or most other popular testers). Refer https://www.servicenow.com/community/itom-forum/help-on-event-rule-regex/td-p/940458
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 06:48 AM
Hello Amit,
Thank you for taking the time to review and reply!
I can confirm that the regex is being saved as: \((.*)\\.*
I am testing my regex using the following steps provided by ServiceNow: How to test Event Management regular expressions using regex101 - Support and Troubleshooting (servi...
All tests are passing, however I am still not able to refresh the rule with a new event. For some reason, it continues to throw the error I screenshotted in the initial post.
Thanks again!
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:29 PM
Hi @Rob M1
Please check if any of the below links is helpful :
https://www.servicenow.com/community/developer-forum/event-rule-regex/m-p/2527383
https://www.servicenow.com/community/itom-forum/regex-in-event-rule-not-working/m-p/2597700/page/3
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:02 AM
Thanks again Amit!
Unfortunately I've already found these articles in my research and none of them seem to address the issue I am experiencing.
I have opened a case with support so I will update this post if/when ServiceNow is able to find a resolution.
Thanks again!
Rob