- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 03:16 AM
Hi Team,
We have created a field called review date in knowledge article. The review date should be updated when published date changes. For example if the published date is today review date should be six months to current date. Can you provide script which I can incorporate over business rule
Regards,
B Siva Teja
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 04:42 AM
Hi @Ballela Siva Te ,
Something like below should be able to do the trick:
(function executeRule(current, previous /* previous values from the form */) {
// Get the published date from the current record
var publishedDate = current.published_date; // Change 'published_date' to the actual field name
// Check if the published date is populated
if (publishedDate) {
// Calculate the review date (6 months ahead)
var reviewDate = new GlideDateTime(publishedDate);
reviewDate.addMonthsLocalTime(6);
// Set the review date in the appropriate field
current.review_date = reviewDate; // Change 'review_date' to the actual field name
}
})(current, previous);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 05:21 AM
Hi @Ballela Siva Te ,
Try below script in your business rule.
if (current.published != previous.published) {
var reviewDate = new GlideDateTime(current.published.getDisplayValue());
reviewDate.addMonths(6);
current.u_review_date = reviewDate;
}
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand