8

In Apex triggers we have Trigger.isUpdate and Trigger.isInsert booleans to check the type of trigger.

How do we get access to those booleans in a lightning flow? Knowing this would be useful in flows that execute when record is created or updated. enter image description here

2 Answers 2

13

Record-triggered flows for new and updated records now support the ISCHANGED, ISNEW, and PRIORVALUE formula functions. Copy your Process Builder or workflow rules formulas containing these functions into record-triggered flows. None of these formula functions are available in flows triggered when a record is deleted.

When copying formulas containing ISCHANGED and PRIORVALUE into record-triggered flows, use the $Record global variable instead of the object. For example, to use ISCHANGED(account.x) in a record-triggered flow formula, change it to ISCHANGED($Record.x). The ISNEW formula function requires no changes because it has no parameters.

Reference:- Use ISCHANGED, ISNEW, and PRIORVALUE in Record-Triggered Flow Formulas

enter image description here

You can use it in decision element like this:-

enter image description here

Note:- This feature is available in summer 21 release, i.e. flow with api version 52.0

2
  • this is a summer 21 feature
    – cropredy
    Commented May 28, 2021 at 18:59
  • This requires a decision element within the flow, but you can check if the record is new within the flow entry conditions itself.
    – Diego
    Commented Dec 3, 2021 at 18:06
10

Unfortunately you can't use formulas in the entry conditions for a flow, but there are a few hacks for checking if the record is new within the entry conditions.

  1. In a before-save flow (i.e. "fast field updates"), you can check if the Record ID is null. record id is null
  2. In an after-save flow (i.e. "actions and related records"), you can check if the Created Date was changed. created date is changed

These can be used in conjunction with any of the other filters available, which allows your flow to handle more nuanced situations. For example, if I want to send an email when

  1. a record already has an agent and the status becomes "pending"
  2. or when a record is created with both an agent and "pending" status

entry condition example

If I had been unable to check for insertion, I would have had to add decision elements within the flow, which is less efficient as our conditions above prevent the flow from ever being entered in the first place (verifiable in the logs).

1
  • 2
    The CreatedDate check was handy, thank you. It's weird to me that Is Changed would register for that field on a create but not other fields. Commented Mar 28, 2022 at 18:16

You must log in to answer this question.

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