Kb articles need to be updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 03:04 AM - edited 08-17-2023 03:05 AM
Hi,
We need a Fix Script
Requirement:
Need to update the kb articles where ever we have the Get Help is mentioned. Something like regular expression.
becuase we see there is some get help also mentioned in the articles.
It converts upper case "Get Help" to "IT Help" in short description and articles body as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 03:36 AM
Hello @Saib1
You can use a script to update the KB articles. Here is a sample script that you can use:
var gr = new GlideRecord('kb_knowledge');
gr.query();
while (gr.next()) {
if (gr.short_description.indexOf('Get Help') > -1) {
gr.short_description = gr.short_description.replace(/Get Help/g, 'IT Help');
}
if (gr.text.indexOf('Get Help') > -1) {
gr.text = gr.text.replace(/Get Help/g, 'IT Help');
}
gr.update();
}
This script will:
- Create a new GlideRecord on the 'kb_knowledge' table.
- Query all the records in the table.
- Loop through each record.
- If the 'short_description' field contains 'Get Help', it will replace it with 'IT Help'.
- If the 'text' field (which is the body of the article) contains 'Get Help', it will replace it with 'IT Help'.
- Update the record.
Please note that this script will replace all occurrences of 'Get Help' with 'IT Help', regardless of the case. If you want to only replace 'Get Help' when it is in upper case, you can use the regular expression /Get Help/gi instead of /Get Help/g.
Also, please be aware that this script will update all the KB articles in your instance. If you want to limit the update to a certain category of articles, you can add a condition to the query, like this:
gr.addQuery('category', 'your_category');
Replace 'your_category' with the actual category you want to update.
Please mark it Correct and Hit Like if you find this helpful!
Regards,
Karthiga