- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 11:41 PM
I have below Requirement Can any body help how can i achieve this
WHEN a user checks out a knowledge article
AND that article is checked out for more than 14 days old
THEN the system should delete the draft article
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 02:22 AM
Hi,
Based on your question, it is assumed you've enabled the 'Knowledge Management Advanced' plugin which provides the 'Check out' functionality.
You therefore need to manage the Knowledge versions (kb_version table).
There is no 'Check out date' to reference, so unless you've implemented something similar, we can obtain a very similar result set you're after by viewing versions that have not been updated over the last 14 days and are in the Draft state.
See below script. Please ensure you run this with the commented lines first so as to verify the records and count prior to actually deleting the record.
Copy this script and create a 'Fix Script' to run these. I assume this also is not a one off? Therefore you'd also need to run this as a scheduled job.
To help others, please mark correct and/or helpful.
Thanks,
Robbie
var count = 0;
var encQ = "sys_updated_onRELATIVELT@dayofweek@ago@14^knowledge.workflow_state=draft”;
var kbvGR = new GlideRecord('kb_version');
kbvGR.addEncodedQuery(encQ);
kbvGR.orderByDesc('sys_updated_on');
kbvGR.query();
while(kbvGR.next()){
kbvGR.setWorkflow(false); // Ensure no other Business rule or logic is triggered
gs.log('Article version to remove: ' + kbvGR.knowledge.number);
count++;
//un-comment the below line once you've verified the result set and count are correct and you are ready to delete the version records
//kbvGR.deleteRecord();
}
gs.log(‘Count:’ + count)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 02:22 AM
Hi,
Based on your question, it is assumed you've enabled the 'Knowledge Management Advanced' plugin which provides the 'Check out' functionality.
You therefore need to manage the Knowledge versions (kb_version table).
There is no 'Check out date' to reference, so unless you've implemented something similar, we can obtain a very similar result set you're after by viewing versions that have not been updated over the last 14 days and are in the Draft state.
See below script. Please ensure you run this with the commented lines first so as to verify the records and count prior to actually deleting the record.
Copy this script and create a 'Fix Script' to run these. I assume this also is not a one off? Therefore you'd also need to run this as a scheduled job.
To help others, please mark correct and/or helpful.
Thanks,
Robbie
var count = 0;
var encQ = "sys_updated_onRELATIVELT@dayofweek@ago@14^knowledge.workflow_state=draft”;
var kbvGR = new GlideRecord('kb_version');
kbvGR.addEncodedQuery(encQ);
kbvGR.orderByDesc('sys_updated_on');
kbvGR.query();
while(kbvGR.next()){
kbvGR.setWorkflow(false); // Ensure no other Business rule or logic is triggered
gs.log('Article version to remove: ' + kbvGR.knowledge.number);
count++;
//un-comment the below line once you've verified the result set and count are correct and you are ready to delete the version records
//kbvGR.deleteRecord();
}
gs.log(‘Count:’ + count)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 07:16 AM
Hi,
Just circling back regarding your question. Did you implement the changes advised in my response?
To help others, please mark my response correct and/or helpful.
Thanks,
Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2022 07:17 AM
Hi,
Just circling back regarding your question. Did you implement the changes advised in my response?
To help others, please mark my response correct and/or helpful.
Thanks,
Robbie