Auto-Close Knowledge Feedback Tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 06:21 AM
I am trying to create a scripted enhancement in ServiceNow to Auto-Close Knowledge Feedback Tasks (KFTs) after 5 Days in "Resolved" State
Script I have generated thus far:
var kft = new GlideRecord('kb_feedback_task');
kft.addEncodedQuery('state=4');
kft.query();
while (kft.next()) {
var date = gs.nowDateTime();
var dur = gs.dateDiff(kft.u_resolved, date, true);
var convertsecondstodays = parseInt(dur) / (60 * 60 * 24);
if (convertsecondstodays >= 5) {
kft.state = '10';
kft.active = false;
kft.update();
}
}
Any assistance or recommendations that you might have would be greatly appreciated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 07:25 AM
Hi,
You can use below logic as well.
var queryTime = new GlideDateTime();
queryTime.addDaysUTC(-5);
var kft = new GlideRecord('kb_feedback_task');
kft.addEncodedQuery('state=4'); // 6 is resolved as per OOB setup
kft.addQuery('u_resolved_at', '<', queryTime);
kft.query();
while (kft.next()) {
kft.state = '10'; // 3 is closed as per OOB setup
kft.active = false;
kft.update();
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 02:24 AM
Hi @Anil Lande
when I this script it's closing incident next after resolved while I am using addDaysUTC(-5) and same script