Valid To field on Knowledge

alexm1
Tera Contributor

Hello,

I need to update the field valid_to from the knowledge form based on the following conditions:

 1. When the article is published, then the "valid_to field of the article must be extended by 'one year' from the date of publication of the article.

2. If the Article is Rejected(kb will return to draft state), then the "valid_to"  should be populated with the latest sys_update_on value.

3.  If the Article is in  state draft, review or waiting for approval the "valid_to" should be populated with the latest sys_update_on value.

What is the best approach to do this?

Thanks,

Alex

 

 

1 ACCEPTED SOLUTION

Write a before business rule with condition as 

and script:

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();
}

View solution in original post

5 REPLIES 5

MarkMullens
Mega Explorer

I am having trouble with this one.

I have created the business rule as such.

Table: kb_knowledge

When To Run:

When: Test both before and after (Insert and Update both checked)

Condition Workflow changes

Nothing in Actions

Advanced: 

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();
}

 

 

I am really only needing to have the Valid To date automatically set to 1 year out from published and/or updated on.

However, this never triggers and my valid to stays where ever it is at the moment despite updating and changing published field.

 

Please help and thank you.

 

-Mark Mullens