Insert can read field values in knowledge article in bulk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2022 11:51 AM
Background script to update can read field in knowledge article tries to delete existing can read user creteria while scripting. How script can be written to insert a new can read creteria existing in user criteria records without effecting exiting can read in articles.this should be done through background script as this is bulk activity for hr related kb to be accessible for respective group only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2022 11:58 AM
// Get the knowledge article that you want to update
var kb = new GlideRecord('kb_knowledge');
kb.get('<knowledge_article_sys_id>');
// Get the existing "can read" criteria for the knowledge article
var existingCriteria = kb.getValue('can_read');
// Add the new "can read" criterion to the existing criteria
var newCriteria = existingCriteria + '<new_criterion>';
// Update the knowledge article with the new "can read" criteria
kb.setValue('can_read', newCriteria);
kb.update();
This script assumes that you have the sys ID of the knowledge article that you want to update, and that you know the value of the new "can read" criterion that you want to add. You can use this script in a background script to add the new criterion to multiple knowledge articles at once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2022 01:57 AM
Hi,
Thanks for help. This seems working but some delete actions are recorded which are not known and not sure why it is showing delete insert and update after running script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2022 03:11 AM
If you could share the execution messages I can analyze them,
Please mark the above solution as an Accepted solution if it has helped you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2022 05:12 AM
 hi please find these records are showing deleted.
But when I checked no records are deleted or no changes happened