Retire KB Automatically

rc393g
Kilo Explorer

Hi All,

I would like to seek you help on how I can verify that our Knowledge Article will be retired after the valid to date. Will this be OOB in Fuji for Knowledge Management.

Appreciate your help!

1 ACCEPTED SOLUTION

Tanaji Patil
Tera Guru

Hi,



Use this code-



var kb = new GlideRecord('kb_knowledge');


kb.addQuery('workflow_state','!=','retired');


kb.addQuery('valid_to','<',gs.now().toString());


kb.query();


while(kb.next()){


  var workflow = new Workflow();


  workflow.cancel(kb);         //this will cancel all workflow contexts with the record


  kb.workflow_state = 'retired';


  kb.update();


}



This should work.



If you are using workflow for knowledge article flow then I would recommend you to use 'Wait for condition' with condition 'valid to at or before Today' followed by 'Set values' activity.



Have a good day



Thanks,


Tanaji


View solution in original post

11 REPLIES 11

Tanaji Patil
Tera Guru

Hi,



Use this code-



var kb = new GlideRecord('kb_knowledge');


kb.addQuery('workflow_state','!=','retired');


kb.addQuery('valid_to','<',gs.now().toString());


kb.query();


while(kb.next()){


  var workflow = new Workflow();


  workflow.cancel(kb);         //this will cancel all workflow contexts with the record


  kb.workflow_state = 'retired';


  kb.update();


}



This should work.



If you are using workflow for knowledge article flow then I would recommend you to use 'Wait for condition' with condition 'valid to at or before Today' followed by 'Set values' activity.



Have a good day



Thanks,


Tanaji


Hi,

I had used this script but there is a small issue I am facing is that if a article has valid to date of today then the will retire on the day after tomorrow.Can you help me what is the issue I am facing here.I have attached the screenshot for scheduled job.