- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 03:30 AM
Hello experts, I have a following email body. I want to fetch the 'Critical' value and store it in some variable in inbound action script . I also have the regex expression Alert Level: (.*).
Can any1 tell me how to retrieve the value 'critical' and store it in a variable.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 03:40 AM - edited 01-31-2023 03:55 AM
Hi @Deepika54 ,
you can get value like this
var alert=email.body.alert_level; //you can get value of alert value like this
or try below it gives the Critical value
var bodyis=email.body_text; //gives you complete body of email
var alerttext=bodyis.split('Alert Level:')[1]; //This gives you text after Alert Level
var gettext=alerttext.split('HostName:')[0];//this gives the text before HostName
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 05:47 AM
Hi @Deepika54 ,
yes that will work.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 03:40 AM - edited 01-31-2023 03:55 AM
Hi @Deepika54 ,
you can get value like this
var alert=email.body.alert_level; //you can get value of alert value like this
or try below it gives the Critical value
var bodyis=email.body_text; //gives you complete body of email
var alerttext=bodyis.split('Alert Level:')[1]; //This gives you text after Alert Level
var gettext=alerttext.split('HostName:')[0];//this gives the text before HostName
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 03:55 AM
are you sure. because in my emai record in the body field, it contains data in this format: Example
</div>
<p class="MsoNormal"><br>
<b>Alert Type: </b>THRESHOLD <br>
<b>Alert Level: </b>Critical<br>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 04:23 AM
dear @Pavankumar_1 thank you for your help but the script is not working as expected.
using this
var alerttext=bodyis.split('Alert Level:')[1];
I am getting the entire string from critical to the last example : the output i am getting is this:
Critical
HostName:
Device IP:
Model: Acropolis Hypervisor
Parameter: Availability
i.e the entire string after critical. How to get only the value critical.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 04:28 AM
Hi @Deepika54 ,
That is correct I am trying to get the after Alert Level: and before HostName .
That is the required text you need right.
gettext variable will give the desired value.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar