- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:40 AM
Hi All,
Trying to run a background script to replace "author" in some KB articles.
Below is the script, executing which returns "***Script:0". Kindly assist as to what is wrong in the below script
var obj= new GlideRecord('kb_knowledge');
obj.addQuery('author','8aef1935474321009db4b5b08b9a7113'); //sys of the author to be replaced from KB articles
obj.query();
gs.print(obj.getRowCount());
while(obj.next())
{
obj.author= 'e6f8e8cb4f52320065fa4a318110c7f7'; // this sys id replaces as the new author for KB articles
obj.setWorkflow(false);
obj.update();
}
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:50 AM
Replace the query that you obtain from the list view, in this script and execute it.
var obj= new GlideRecord('kb_knowledge');
obj.addEncodedQuery(query); //Replace your query here
obj.query();
gs.print(obj.getRowCount());
while(obj.next()){
obj.author= 'e6f8e8cb4f52320065fa4a318110c7f7';
obj.setWorkflow(false);
obj.update();
}
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:45 AM
The sys_id of author should be incorrect or there are no articles with the above user as author.
Can you apply this filter on the knowledge article list view and copy its query once
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 03:50 AM
Replace the query that you obtain from the list view, in this script and execute it.
var obj= new GlideRecord('kb_knowledge');
obj.addEncodedQuery(query); //Replace your query here
obj.query();
gs.print(obj.getRowCount());
while(obj.next()){
obj.author= 'e6f8e8cb4f52320065fa4a318110c7f7';
obj.setWorkflow(false);
obj.update();
}
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 01:06 AM
Hi Alikutty, thanks a ton for you asisstance