HTTP Callout restriction doesn't allow Record-Triggered Flow to run on updates

736 Views Asked by At

I'm running into a strange issue with my Record-Triggered Flow in Salesforce.

Basically, whenever a record is created or updated in Salesforce, we want to send a message to an external API. The problem is that only created records are running successfully in the Flow, updated records don't run. We see a message saying

The triggering record didn’t meet the condition requirements, so the flow didn’t run

There's a chain of issues resulting from using the HTTP Callout that led to this. The first is that they can't be under the Run Immediately path, otherwise we get this error.

A record-triggered flow can’t execute actions that make external callouts in a path that runs immediately.

So we created another scheduled path, with the Time Source being "When Record is Created or Updated" with the Time Source set to 0, so it will run immediately.

But this gives us another issue, in that the path requires Entry Conditions, we get this error if we try to set the Condition Requirements to "None":

This flow has a scheduled path with a time source based on when a record is created or updated. Configure the flow to run only when a record is updated to meet the condition requirements.

So we set up a Condition Requirement, something that would always be true, like "Id is not null", and set the Flow to run "Every time a record is updated and meets the condition requirements". But then we get this error trying to save it:

This flow has a scheduled path with a time source based on when a record is created or updated. Configure the flow to run only when a record is updated to meet the condition requirements.

Finally, we set the Flow to run "Only when a record is updated to meet the condition requirements".

But that leads us to our problem, in that the flow will only run if the Entry Conditions change from not meeting the requirements, to meeting the requirements. Ex: it will only run if the Id on the record changed from null to not null.

So updates aren't running because the Id field isn't changing. But due to the limitations of the HTTP Callout, I can't see any way around these restrictions to make the Flow run every single time. Is there a way around this? Or an Entry Condition I can set up that would fix this?

3

There are 3 best solutions below

2
On

The flow is designed to trigger only when a record is updated and the condition requirements change. However, your requirement is to have the flow execute on every update, regardless of whether the condition requirements change.

A possible solution would be to use a formula field on the record that changes each time the record is updated (see "Tips for Referencing Record Types in Formulas"). That field could be a timestamp or a counter that increments on each update. That way, the flow's condition will always be met, triggering the HTTP Callout.

For example, you could create a formula field named LastModifiedDateFormula with the following formula:

TEXT(LastModifiedDate)

"Then, set your flow's condition to check if LastModifiedDateFormula is not null (which it always will be). That will make sure your flow runs on every update."

Wouldn't that lead to the same problem I had? Since the Flow can only be set to run "Only when a record is updated to meet the condition requirements"

If it's checking whether that field is not null, and it will never be null, it wouldn't trigger since the field isn't changing from null to not null

True: the Salesforce Record-Triggered Flow is designed to execute only when the conditions change from not being met to being met. If the condition is based on a field (LastModifiedDateFormula) that is always non-null, the flow might not trigger as intended because the condition does not change from false to true.

Given this limitation, consider instead a timestamp comparison.

Create two timestamp fields:

  • LastModifiedDateFormula: That remains as a formula field with the formula TEXT(LastModifiedDate).
  • PreviousUpdateTimestamp: That is a new DateTime field that stores the timestamp of the previous update.

The flow's condition would check if LastModifiedDateFormula is different from PreviousUpdateTimestamp. If they are different, it indicates that the record has been updated.

After the HTTP Callout action, add an action to update PreviousUpdateTimestamp with the current LastModifiedDate value. That makes sure on the next update, the condition will be re-evaluated correctly.

0
On

I think, I can solve your problem. Please check my suggestions.

This happen because HTTP Callout don't run immediately after db record / sales force doesn't allow that. So HTTP Callouts must run in asynchronous mode.

1) Did you mark this box. enter image description here

1
On

You can add in the block multiple conditions with isChanged operator. The flow will be trigger if the condition is changed, not necessarily true. That’s why you can add a condition with isChanged operator and add the async path for the http callout. Also, don’t forget about named credentials and permission sets.