- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:15 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:50 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:39 AM
Thank you for your response, how should the conditions look like?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:50 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 06:54 AM
@dvp has replied with a sample query i see. Hope this helps.
If yes, please mark both of our answers Helpful.