0

I am trying to create a screen flow without using a loop to display "Nearby Accounts" (within 10 miles). However I am getting an error as seen in the below screenshot. I am fairly new to using formulas in flow so any help would be much appreciated.

Here is the screen shot of the formula in a Collection Filter: enter image description here

Formula: IF(DISTANCE( GEOLOCATION({!recordId.BillingLatitude} , {!recordId.BillingLongitude}), GEOLOCATION({!currentItem_Collect_Accounts_WIthin_10_miles.BillingLatitude}, {!currentItem_Collect_Accounts_WIthin_10_miles.BillingLongitude}), 'mi') <10)

Here is an overview of my flow: enter image description here

For context I am not using a loop because our org has too many accounts as when implementing a loop the number of iterations are exceeded.

What I want the formula in the collection filter to achieve is to return Accounts that are within 10 miles of an Account.

5
  • Please edit your post to include the error text and show the details of what the step is doing. Jan 20, 2023 at 16:23
  • @DavidCheng sorry about this I forgot to add the screenshot of the formula. I hope this makes sense.
    – Timmy
    Jan 20, 2023 at 16:41
  • 1
    If DISTANCE and GEOLOCATION are permitted in a formula, you need to make sure the IF has the three parameters. So here something like IF(DISTANCE(...) < 10, TRUE, FALSE)
    – Phil W
    Jan 20, 2023 at 16:49
  • I must say, it's annoying you cannot do a DISTANCE calculation/filter in the Get Records element itself.
    – Phil W
    Jan 20, 2023 at 17:50
  • Hi guys, I have managed to get this working! @PhilW thank you. I have achieved it by using the following formula in the Collection Filter: IF(DISTANCE( GEOLOCATION({!recordId.BillingLatitude} , {!recordId.BillingLongitude}), GEOLOCATION({!currentItem_Collect_Accounts_WIthin_5_miles.BillingLatitude}, {!currentItem_Collect_Accounts_WIthin_5_miles.BillingLongitude}), 'mi') <5, TRUE, FALSE)
    – Timmy
    Jan 23, 2023 at 8:53

1 Answer 1

0

The IF function always takes three parameters. You need to update your IF so it has the condition and the two resulting values. Since you are only interested in whether the condition is met (or not) you need to make it something like:

IF(DISTANCE(...) < 10, TRUE, FALSE)

I have left out the detail passed to the DISTANCE function for clarity.

This says, if the condition (here the check for distance) is met then return TRUE otherwise return FALSE.

You must log in to answer this question.

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