2

My company has just started using Contracts. I created a value in the Status picklist called Expired for expired contracts. My goal is to automate setting the value to Expired without asking the sales reps to do this.

I am trying to accomplish this with a time based workflow rule. The logic I am using is:

1- Evaluation Criteria: Evaluate the rule when a record is created, and any time it's edited to subsequently meet criteria Description

2- Rule Criteria: Contract: Contract End Date NOT EQUAL to null

3- Time Trigger: 0 Hours after Contract: Contract End Date

4- Workflow Action: Field Update on Contract Status to Expired

However, this does not seem to be working. Is there something I am missing? Or should I be using a different method than workflow?

Thank you all so much!

enter image description here

1
  • note that WFRs are deprecated and if this is de novo work, strongly consider using record-triggered flows with scheduled paths as that is the replacement for time-based workflows
    – cropredy
    Commented Dec 19, 2021 at 1:37

2 Answers 2

2

It's important to note that while this automation is set up correctly, affected records must be edited at least once in order to be scheduled by the system. In other words, you will need to use an ETL (Extract-Transform-Load) tool, such as the Apex Data Loader, to queue all of these records for later execution. Any records created after the rule is active should work fine. You can check the status of the records in Environments > Monitoring > Time-Based Workflow. You could also set up a Scheduled Flow to query for records to be updated and set it to run every night; this has an advantage of not needing to load all existing records to enqueue them, and has higher limits.


Edit: The Scheduled Flow should look like:

Update Expired Contracts Flow

And the Formula:

Today Formula

The Get Records element:

Get Records

7
  • Thank you so much @sfdcfox The Scheduled flow worked. I had to create a checkbox formula that updates to True once the EndDate < Today() because I didn't see a way to input a relative date in the Flow conditions. I built the Flow to look for the TRUE values in the formula field then update those records to Status = Expired every morning at 12:15am. It's working just as planned in the Sandbox. Once my boss approves, I can then push it into Production. Thanks again! Commented Dec 21, 2021 at 15:45
  • @ChristianBurnett You can create a Formula with {!TODAY()}, then you have a relative date for use in your Scheduled Flow. I'd avoid a formula as that creates a Full Table Scan scenario, which may eventually cause problems.
    – sfdcfox
    Commented Dec 21, 2021 at 15:49
  • Would this be in a Decision Element? If so, what kind of formula would that be? This is the first flow I have built so I am very new to this. Thank you again for your help Commented Dec 21, 2021 at 18:31
  • @ChristianBurnett One sec, I'll build you one.
    – sfdcfox
    Commented Dec 21, 2021 at 18:34
  • 1
    @ChristianBurnett See the screenshot an explanation. It's really pretty simple.
    – sfdcfox
    Commented Dec 21, 2021 at 18:44
0

Since you already have an end-date, it would be much easier to implement this as a formula field. You could basically display the Status field als long as EndDate > TODAY. Once it surpassed today, you display Expired (if you use a label, the value is also translated).

You only need a minor tweak in your status picklist to reflect, that the contract wasn't terminated/cancelled (but may still be expired).

Your formula would look like this:

IF(
  EndDate > TODAY(),
  Status,
  System.Label.Expired
)
2
  • Hi J. Schreiber. I ended up building a scheduled Flow that seems to be working as a solution. However, our of curiosity, where would I put this formula? Thank you! Commented Dec 21, 2021 at 15:47
  • Right on the contract object. It's much quicker, cleaner and more robust to use a formula field (as long as the requirements allow it, because the solutions are not 100% identical) Commented Dec 21, 2021 at 22:27

You must log in to answer this question.

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