function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ian DacanayIan Dacanay 

Visual Flow - Record Lookup - OR conditionals

When performing a record lookup there doesn't seem to be the ability to perform an OR conditionals only ANDs. For example, when creating your filtering for a report, you can change the conditional action to a custom to filter for 1 AND 2 AND 3 AND (4 OR 5). However this type of custom conditional action is not available in Visual Flow. I've used the conditional DOES NOT EQUAL however that becomes combersome over the long haul. Here's an example:

Within our Campaign object we have a custom field (Campaign_Area_c) with the values of the country and the continental area -> US (united states), CA (canada), NA (north america). If the account is located in the US, then they should be able to see both US and NA related campaigns. 

Now is not so bad, however if you more than one set of these OR conditionals then you end with a visual flow that looks more spaghetti than anything else. Looking for ideas to tackle this issue cleanly.

Regards.
Karen MadiganKaren Madigan
Hi Ian,

This is a contention of mine as well...there has been many times I've wanted to filter for records with an OR condition and have growled at my computer on many occasions when faced with solving the same sort of dilemma you're facing. I've also often thought if I could just have a collection variable with all the values I want, then have a filter that says "CollectionVariable contains FieldValue," but alas, no such luck here, either.

For Fast Lookups I have three possible solutions:
1. Filter for NOT all of the other Campaign_Areas (if you have a lot of areas this may not be a practical solution)
2. Loop through a broad collection of Campaign items and place just the ones you want into a working collection.
3. Add a formula field that designates a broader "division" based on the value of your Campaign_Area

In the first solution, let's say you have NA, US, CA, and MX as possible Campaign_Areas and you want NA and US
Your filter would have these two filters:
Campaign_Area does not equal CA
Campaign_Area does not equal MX

In the second solution do a Fast Lookup to your Campaign items that will include the NA and US records you want to use. For example sake, let's say you saved those records in a collection variable called "BroadCampaignItems." Next loop through all the BroadCampaignItems and if the Campaign_Area equals either NA or US, place the record into a second collection, called something like "WorkingCampaignItems." Now you can do whatever it is you need to do on that set of records.

In the third solution, create a formula field that speficies a value that you can easily use to locate the campaigns in the working region. Something like IF(Campaign_Area="NA" || Campaign_Area="US", "Area1", IF(Campaign_Area="CA", "Area2", "Area3")). You can now do a lookup based on this formula field.

But what if "NA" should be in Area1 and Area2? Write your formula something like this: IF(Campaign_Area="NA", "Area1,Area2", IF(Campaign_Area="US", "Area1", IF(Campaign_Area="CA", "Area2", "Area3"))). And then use the "contains" filter on your lookup: Campaign_Area contains Area1 (see how NA now fits into filtering for either Area1 or Area2?).

For Dynamic Lookups you'll need to use either solution 1 or 3. Unfortunately you can't create a collection and have the dynamic lookup work off of your collection.

Cheers!
chris hoffmeyer 1chris hoffmeyer 1
I was looking for a work around for a similar situation, then I found that Flow does support "OR" but the documentation is pretty slim...  There is one reference in the cloud flow designer guide: https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_designer_elements_record_lookup.htm  Under the heading "Considerations for Defining Filter Criteria".  

Essentualy, You can specify multiple options of the same field when using equals.  ie: 
filed 1 = z
filed 2 = a
field 2 = b
Flow will interpreset this as:  field 1 = z AND (field 2 = a OR field 2 = b)
Jodi_Nemser-AbrahamsJodi_Nemser-Abrahams
There's an Idea to add functionality to record lookups. Please upvote it! 
https://success.salesforce.com/ideaView?id=0873A000000lDvCQAU