- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2020 10:45 PM
Hello All,
I need that if a specific incident's short description is containing incident number, then that incident number should be stored in a variable.
Is there a way in scripting how I can extract that text from the short description? The words are at the 5th position index in the short description.
I tried the following in background script but its not working:-
var gr = new GlideRecord('incident');
gr.addQuery('number','INC0533650');
gr.query();
while(gr.next())
{
var res = sgr.short_description.substring(5, 10);
gs.log("Found it");
gs.log(res);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2020 11:37 PM
Script I tried with your short description and got the incident number
var str = 'INC# INC0528025 / ATT_NI_RMM_VC_ABCDE / 1 - Critical / New / GENERIC DEVICE / test';
var regex = new SNC.Regex('/INC\\d{7}/im');
var match = regex.match(str);
gs.info('Incident number->' + match);
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2021 02:21 AM
Hi David.
I'm having this issue regarding finding values in task short description.
So if my short description field holds this information:
CTD sendt via API, lev. nr. 3310, Bilags nr. 118645, Type: EDI Faktura
I need to get the information after word Type: into the task field "Category".
How would you do that??
I have tryed with this script:
var gam_type = /Type: (.*?)\./g; //new RegExp("Type: (.*?)\.", "g");
var type_match = gam_type.exec(email.subject);
if(type_match && type_match[1]) {
current.category.setDisplayValue(type_match[1].toString());
}
But It dosn't work.
And the Type information can be placed at different positions, as we get the information from customers via mail.
Kind regards,
Janne.