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

Hi,

Don't mean to answer for Goran, he's already got you straight, but to answer your question, yes.

Using [1] grabs the text after the split whereas [0] would get you the text before the split.

Please mark reply as Helpful, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you Allen 🙂

Is it possible to grab just some of the text after the split -  instead of all of it?

 

 

not to be a arsle, but we all like points 😃 Do you consider Allan's answer to be the correct one for your question? (and btw, I also answered your 15 character question on the other subthread of this question 🙂 )

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

Yea, earlier my response wasn't marked as Correct so perhaps that was done at some other time.

Anyways, glad it's all worked out.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Richard Thomas2
Tera Contributor

Ah ok - Sorry Goran I'm just getting my head around how this works - yours was the correct answer - I didnt know that you couldnt mark 2 correct answers!

With regards to your second answer - I missed it - so accept my apologies again!!

Bad day at the office 🙂

Thanks for you help - I truly appreciate it 

Kind regards

 

Rich