Flow designer Action script to last updated is less than 3 months
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:11 AM
Hi
i need to write script
tried this but not working can someone please help
it should not trigger the flow if last updated is less than 3 months
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:18 AM
share that script here and not image.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:30 AM
(function execute(inputs, outputs) {
// Get the current date and time
var currentDateTime = new GlideDateTime();
// Retrieve the input duration in months (e.g., 3 months)
var inputDur = parseInt(inputs.inputDuration, 10); // Convert to integer
// Retrieve the input date (last updated date)
var inputDate = new GlideDateTime(inputs.inputDate);
// Compare the input date to the calculated date
if (inputDate < comparisonDate) {
outputs.flag = currentDateTime; // The record is updated within the last X months
} else {
outputs.flag = false; // The record is not updated within the last X months
}
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:43 AM
try this
(function execute(inputs, outputs) {
// Get the current date and time
var currentDateTime = new GlideDateTime();
// Retrieve the input duration in months (e.g., 3 months)
var inputDur = parseInt(inputs.inputDuration, 10); // Convert to integer
// Retrieve the input date (last updated date)
var inputDate = new GlideDateTime(inputs.inputDate);
// Calculate the comparison date (current date minus input duration in months)
var comparisonDate = new GlideDateTime();
comparisonDate.addMonthsUTC(-inputDur);
// Compare the input date to the calculated date
if (inputDate >= comparisonDate) {
outputs.flag = true; // The record is updated within the last X months
} else {
outputs.flag = false; // The record is not updated within the last X months
}
})(inputs, outputs);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 09:20 AM
Did you try the script I shared above?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader