Business Rule script (?) - Valid To for all articles in all knowledgebases

susan remondi
Tera Contributor

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!

1 REPLY 1

New Developer_S
Giga Sage

Hi Susan,

 

I too have the same  issue , Are you able to find the solution for this ?Could you please post it ?

 

TIA