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

Inactive_Use945
Kilo Expert

You will have to write a Business rule on the Knowledge article table to achieve it. With necessary conditions in place the requirement can be achieved pretty straight forward.

 

When: Before Insert/Update

Order: 100

Condition: current.status.changes()

 

Hope this helps you to give a direction to proceed.

Thank you for your response, how should the conditions look like?

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

@dvp has replied with a sample query i see. Hope this helps. 

If yes, please mark both of our answers Helpful.