- 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 04:46 AM
it is working. Thank you so muchhh pavan.
But i am getting a space before critical. Can u plz tell me how to remove that previous space.
The output i am getting is:
Critical.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 04:58 AM
Hi @Deepika54 ,
add below line to remove.
var finalText=gettext.replace('.', '');
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 05:26 AM
similarly if i want to get the device ip, will these 2 lines work?
var a = bodyis.split('Device IP:')[1];
var b = a.split('Model:')[0];// i will print b
- 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 05:01 AM
i used trim function and it is working. Thank u pavan 😀