Cancel Changes Using Flow designer

El Cuchi
Tera Guru

Hi all,

I want to develop a solution where i cancel all changes (including their change tasks), if they are in NEW state and have not been updated for the last 30 or 60 days (not too relevant).

I created a scheduled job that works and i thought that maybe doing it in flow designer would be better.

 

i created a flow where the trigger is everyday @ 10am

first is a look up records in the change table where state is new (-5) and updated is older than 30 days. Second activity is a "for each" of the records found in the look up. Third activity is another 'for each" where i search for change tasks related to changes from first 'for each' and if they are not closed then i cancel them

Fourth, outside the second 'for each' i do have an activity to cancel the change record (after closing all change tasks.

 

Issue

the result of the lookup is empty (0). After several testings i realised that the date filter (older than 30 days) is causing the issue. if i remove it and leave just state is NEW. Then, it works.

 

I also try replacing the lookup with a custom script but i face the same issue.

 

Question

is it possible that flow cannot cope with this filter? would you know how to do it in flow?

 

regards,

Max

1 REPLY 1

Matthew_13
Mega Sage

Hi Buddy,

 

The issue isnt that Flow can’t handle the filter, it’s that the “older than 30 days” condition doesn’t always evaluate reliably in a Lookup Records step, especially when it’s applied to a date/time field like Updated. Because of that, the lookup ends up returning zero records even though you know matching records exist.

The easiest and most reliable way to fix this is to calculate the date first, and then compare against it.

Try this approach I use and that usually works well:

  • First, get the current date/time in the flow.

  • Then subtract 30 (or 60) days from it.

  • In your Lookup Records step, filter where:

    • State = New

    • Updated is before the calculated date

Using “is before” with a concrete date/time value is much more predictable than using “older than X days”.

Another reliable option is to use an encoded query in the lookup, for example:

state=New^sys_updated_on<javascript&colon;gs.daysAgo(30)

This behaves the same way as list filters and avoids the Flow condition-builder quirks.

Basically:

  • Flow Designer can absolutely do this

  • The “older than” operator is what’s tripping you up

  • Calculating a cutoff date (or using an encoded query) is the clean workaround

Your overall design — scheduled flow, looping through changes, cancelling tasks first, then cancelling the change — is solid.

You just need to tweak how the date filter is handled.

 

@El Cuchi - Please mark Accepted Solution and Thumbs Up if you found Helpful