- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 07:42 AM
Hi Community,
I have a script that works perfectly, apart from the fact that our incident Priority is customised as:
1-Critical, 2-High, 3-Medium
Our script is sent to an external party and needs to pull the current Priority but without the number 1 and - in from of the priority.
Example string below, which current priority, (but should obviously remove the above number and dash)
r.setStringParameterNoEscape('Priority', current.priority);
Is there a way to slice the number and dash that i can return in the above string?
Many thanks
Steve
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 09:12 AM
You're missing a bracket and semicolon after the script I provided. );
r.setStringParameterNoEscape('Priority', current.priority.getDisplayValue().match(/([A-Za-z])\w+/)[0]);
If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved. ✅
By doing so you help other community members find resolved questions which may relate to an issue they're having.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 07:48 AM
Here we go steve:
var str ='1-Critical';
var priority = str.split('-')[1] ;
gs.log("priority :"+priority);
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
ServiceNow MVP 2020
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 08:17 AM
Abhishek,
Thank you for your suggestion, however when I changed the business rule I couldn't see the message pass out of HTTP outbound, where as before is was successfully passing over the API
Kind regards
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 07:51 AM
Hi,
Can you try below
var priorityis=current.priority.split('-')[1];
Whatever is in priorityis is your value Critical, Medium,Low, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2020 08:14 AM
Jaspal,
Thank you for your suggestion, however I get the following error when running the business rule with a status 406
{
"fault": {
"faultstring": "Required Fields Missing or Empty",
"detail": {
"errorcode": "Please fill in all the required fields."
}
}
}
}
Thanks
Steve