Setting valid_to date of Knowledge article to 6 months after published date

neetika
Tera Contributor

Hi all,

I have written a business rule to set the valid_to date of Knowledge article to '6 months after published date'

This runs when n article is published, so an 'After' 'update' BR is used when 'State' changes to 'published'.

(function executeRule(current, previous /*null when async*/) {

var gdt= current.published.getGlideObject();

  //gs.addInfoMessage("time:"+gdt);

  current.valid_to = gdt.addMonthsLocalTime(6);

})(current, previous);

Above is the script, but its not working. Something is missed.

Please correct me.

10 REPLIES 10

Hi neetika.gupta@infosys.com,



Were you able to find the solution?



I tried below AFTER BR for the same, with below condition and script.



CONDITION: current.operation("publish_knowledge") || current.operation("sysverb_update")



(function executeRule(current, previous /*null when async*/) {




  // Add your code here



  var gr = current.published.getGlideObject();


  gs.addInfoMessage('The KB is drafted   on'           +   gr);


    current.valid_to = gr.addMonthsLocalTime(6);


  gs.addInfoMessage('Valid to Date is set to' + valid_to);



The validity date field shows empty does not get set to 6 months after published date. The BR does not work.