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 08:39 PM
Hope you are doing good.
Did my reply answer your question?
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:26 PM
HI @Ankur Bawiskar
tried the script you have provide but getting NaN error, checking on that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 09:29 PM
did you add gs.info() and see?
(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
gs.info('input duration is' + inputDur);
// 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);
gs.info('comparison date is' + comparisonDate.getValue());
// 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-09-2025 08:23 PM
Hope you are doing good.
Did my reply answer your question?
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 06:52 AM
Hello @harinya
I don't think you should be comparing like that.
Use "getNumericValue()" to get the numeric value of both the glideDates, I think one is duration type of field, getNumericValue() should work there as well.
Convert both into this milliseconds and then compare. You are comparing two completely different data types that's the reason.
Show me the input you are passing to this action.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY