0

How can I update a picklist status value to Inactive when a record has passed 31 days After Job End date?

I have a scheduled flow setup on weekly basis and it should check all Active records and update their Status to inactive if the Job End Date has passed 31 days. When I run a debug, it updates incorrect jobs to inactive The Flow should only check records that have end date passed 31 days

Job_End_Date__c greater or equal EndDatePassed (contains below formula)

Formula field-> {!$Record._Job_End_Date__c} + 30

Can someone advise please?

4
  • Welcome to SFSE! Please take a moment to read How to Ask and take the tour. Including avMinimal, Reproducible Example would be helpful. Your verbal description isn't enough to troubleshoot your issue.
    – identigral
    Jul 29, 2022 at 16:43
  • 2
    it looks like you are comparing job end date to job end date + 30 - this can never be true. You need to compare today's date to job end date + 30
    – cropredy
    Jul 29, 2022 at 20:39
  • Interesting, would the formula look something like below? TODAY() + (-1) + {!$Record._Job_End_Date__c} + 30. Would that Today part be in the formula itself or a filter in Get Records which is set after the starts? Aug 1, 2022 at 17:07
  • Not sure how to compare the end date with today, it should pick up records from before or after today that finished 30 days after the Job. @cropredy Aug 1, 2022 at 17:19

1 Answer 1

0

In flow builder the current date is stored in the global variable {!$Flow.CurrentDate}, so you could define a formula ThirtyOneDaysAgo as {!$Flow.CurrentDate} - 31, then in Get Records element the conditions will be:

  1. Job_End_Date__c Less Than or Equal ThirtyOneDaysAgo
  2. Status__c Equals Active.

Another way to achieve this would be creating a Boolean formula field (i.e. Should_Be_Inactive__c) on that object defined as:

TODAY() >= Job_End_Date__c + 31 && ISPICKVAL(Status__c, 'Active')

Then in flow you could just query every record with Should_Be_Inactive__c = TRUE

2
  • this is very helpful - thanks a lot Ruben ! Aug 18, 2022 at 16:39
  • @Flownewbie You're welcome. Please consider to mark helpful answers provided to your questions as accepted, to benefit the whole community. Here you can read why this is a good practice.
    – RubenDG
    Aug 18, 2022 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .