Parsing html description field in incident

Richard Thomas2
Tera Contributor

Hi,

I'm trying to create a before business rule that changes the short description of an incident to something from the description of the incident. I'm trying to parse the description (never done this before!).

Basically - I want to take all the text after Alert Description: in the description and populate the short description with it. I have this script;

current.short_description = u_description_html.indexOf("Alert Description:==14")

Will this work? Be kind - I've new to coding!!

 

Thank you


Rich 

1 ACCEPTED SOLUTION

Hi Richard,

 

If you only need to 15 first, you can use substring function to pull that out. 

var descSplit = current.description.split('Alert Description:');
current.short_description = descSplit[1].substring(0,14);

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor’s Guide To ServiceNow

View solution in original post

10 REPLIES 10

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

if you want to do it code-wise, this would do it:

var descSplit = current.description.split('Alert Description:');
current.short_description = descSplit[1];
 
//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor’s Guide To ServiceNow

Thank you - that works perfectly.

 

Final question is it possible to limit the characters that I'm bring over from the description...? I probably only need to use the first 15 characters.

 

Thanks for your help

Rich

Hi Richard,

 

If you only need to 15 first, you can use substring function to pull that out. 

var descSplit = current.description.split('Alert Description:');
current.short_description = descSplit[1].substring(0,14);

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor’s Guide To ServiceNow

Richard Thomas2
Tera Contributor
Ah ok - thank you Goran - I will try this in the morning. Will that take all of the text after ‘Alert Description’? Regards Rich