Autoclose Knowledge Feedback tasks

kumar junior11
Tera Contributor

When a KB Feedback Task has been in the Resolved State for more than 2 Days (48 Hours), it should be automatically moved to the Closed state. help me  with the best solution.

 

 

thanks in advance,

regards

saikumar

16 REPLIES 16

Mark Manders
Mega Patron

Depending on how you are looking at it, you could create a scheduled job, run it daily and close all of the ones that have been resolved longer than 48 hours.

Or you create a flow that triggers on resolving a task, add a 48 hour wait and then close it (including logic for reopening and such).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

hi @Mark Manders  im using flow designer , can you look the steps and suggest me anything wrong here

kalalisaikumar_0-1716289769090.pngkalalisaikumar_1-1716289856569.pngkalalisaikumar_2-1716289876092.png

 

You are triggering it only once. So the first update the record gets, will trigger the flow and then never again. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Robbie
Kilo Patron
Kilo Patron

Hi @kumar junior11,

 

This is easily achieved by creating a Scheduled Job.

Simply type 'Scheduled Job' and click on the entry under 'System Definition'. Create a new job and set a time this should run daily using the following code in the 'Run this script' field:

 

 

autoCloseKBF();

function autoCloseKBF() {
    //var daysAgo = gs.getProperty('kbf.autoclose.time'); // Best practice and recommendation - Create a system property so this value can easily be changed or hardcode as below
    var daysAgo = '2'; // hardcoded value
    var daysAgoNumber = parseInt(daysAgo);
    var queryTime = new GlideDateTime();
    queryTime.addDaysUTC(-daysAgoNumber);

    if (daysAgoNumber > 0) {
        var kft = new GlideRecord('kb_feedback_task');
        kft.addEncodedQuery('state=6');
        kft.addQuery('u_resolved_at', '<', queryTime);
        kft.query();
        while (kft.next()) {
            kft.state = '3';
            kft.active = false;
            //kft.work_notes.setJournalEntry('Feedback Task automatically closed after ' + daysAgoNumber + ' days in the Resolved state.'); // Uncomment if you wish to add a worknote - recommended.
            //kft.setWorkflow(false); //uncomment this line if you don't want to trigger other business rules/log etc
            kft.update();
        }
    }
}

 

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.

 

Thanks, Robbie