Business Rule script (?) - Valid To for all articles in all knowledgebases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:36 AM
Goal: Yearly review for KB articles where if they aren't reviewed, they are retired. I'm trying to set "Valid To" on any KB articles newly published or if the KB is updated to one year from the date published or the date an update is published.
I found 4 posts with scripts in the community on how to write the script (but they're all different...), being this post , this post, this post , and this post . None of them are working for me. I think this is because I have two KnowledgeBases (but I am not sure).
My business rule is set to a global application, Active, on table kb_knowledge. I am copying the scripts between the provided execute rule function. So my code under Advanced looks like:
(function executeRule(current, previous /*null when async*/) {
var gdt = new GlideDateTime();
if(current.workflow_state == 'published'){
gdt.addYearsUTC(1);
current.valid_to = gdt.getDate();
}
else if(current.workflow_state == 'draft' || current.workflow_state == 'review' ){ // Add more states if needed
current.valid_to = gdt.getDate();
}
})(current, previous);
This does not work - every new article I make still has the default valid to of 2100-01-01.
Can anyone help? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 12:02 AM
Hi Susan,
I too have the same issue , Are you able to find the solution for this ?Could you please post it ?
TIA