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 07:58 AM - edited 04-07-2025 07:59 AM
@Shivalika Input date is specific record updated
input Duration as 3
both i am giving from Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 08:05 AM
Ok @harinya
I get it input date is a "GlideDateTime()" type field, so input duration is "3" - what ? What's the unit ? Just 3 integer ?
Now I am sure it's breaking because comparison is not correct.
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2025 10:32 PM
Hello @harinya,
Please use the input variables as integer and date for duration and input date respectively. this will avoid one more line of code to skip parsing integer.
With this change, please use below script to achieve your goal.
(function execute(inputs, outputs) {
// Get the current date and time
var currentDateTime = new GlideDateTime();
gs.info('current date is' + currentDateTime );
// Retrieve the input duration in months (e.g., 3 months)
var inputDur = inputs.inputDuration; // Get the parsed integer input in this variable.
gs.info('input duration is' + inputDur);
// Retrieve the input date as per your expectations.
var inputDate = new GlideDateTime(inputs.inputDate);
// Calculate the comparison date (current date minus input duration in months)
var comparisonDate = new GlideDateTime();
comparisonDate.addMonthsLocalTime(-inputDur); // Negative means subtracting integer value of month from the current date.
gs.info('comparison date is' + comparisonDate.getValue());
// Compare the input date to the calculated date
if (inputDate >= comparisonDate) {
outputs.flag = true; // if input date is less than new comparison date
} else {
outputs.flag = false; // if input date is greater than new comparison date
}
})(inputs, outputs);