Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Word count on KB article and body

Rajanandhini Ra
Tera Contributor

Hello,

I have 2 fields in the kb form to get statistics value of KB title and Article. Can someone help me on this?

1 ACCEPTED SOLUTION

Gunjan Kiratkar
Kilo Patron

Hi @Rajanandhini Ra ,

Try to use below script and set your values as the variables. Below is sample script to get the counts.

var ka = new GlideRecord('kb_knowledge');
ka.get('3f2077cf53022200d901a7e6a11c08e4'); //kb article sys id

var title = ka.short_description.toString();
var titleWordCount = title.split(" ").length;

var content = ka.text.toString();
var contentWordCount = content.split(" ").length;

gs.info("Title Word Count: " + titleWordCount);
gs.info("Content Word Count: " + contentWordCount);

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

1 REPLY 1

Gunjan Kiratkar
Kilo Patron

Hi @Rajanandhini Ra ,

Try to use below script and set your values as the variables. Below is sample script to get the counts.

var ka = new GlideRecord('kb_knowledge');
ka.get('3f2077cf53022200d901a7e6a11c08e4'); //kb article sys id

var title = ka.short_description.toString();
var titleWordCount = title.split(" ").length;

var content = ka.text.toString();
var contentWordCount = content.split(" ").length;

gs.info("Title Word Count: " + titleWordCount);
gs.info("Content Word Count: " + contentWordCount);

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy