Setting valid_to date of Knowledge article to 6 months after published date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2017 06:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 08:37 AM
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.