ss

In Visibility Rules, “Contains” means a regular expression, not a simple string match

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator

Little-publicized, to the point that even Support might not be in the loop: the Visibility Rule Contains operator does allow multiple values.

The Contains value is interpreted as a full-fledged regular expression, so use the pipe character | to separate sub-values:

ss

In fact, because of this unexpected/undocumented power, you must anchor an expression to avoid surprises:

^(TX|FL|PA)$ 

Otherwise, it's doing a partial match of the full value against each of your pipe-delimited alternatives. This might not be a problem on your forms right now, but if it becomes a problem, you wouldn't know about it immediately.

For example, if you were using uppercase state names, then

     Contains KANSAS|IDAHO

would match both ARKANSAS and KANSAS, and you should use

     Contains ^(KANSAS|IDAHO)$

instead.

You can also of course do more fancy matches with regexes if you want. And Not Contains is also a regex!

1346
5
5 Comments
KellyJoHorton
Level 3

You just made my day. :^)

Jace_Garside1
Level 2

I just tried implementing this to have rich text appear if a generic email is entered - sort of a quasi way to discourage personal email addresses without completely denying them. But it only recognizes the first value I have listed.  Any thoughts?

Jace_Garside1_0-1618613225064.png

 

SanfordWhiteman
Level 10 - Community Moderator

That particular regex isn't what you want because it's checking if the value begins with the email domain. See my answer on your new thread: https://nation.marketo.com/t5/Product-Discussions/Visibility-Rules-with-Multiple-Values-within-Crite...

BenCirillo
Level 2

Is there an expression that would work if I wanted to do the opposite: display values if Value A and Value B are true. 

 

I'm trying to do something like this (not this, but like this): 

Q: What topics are you generally interested in? 

(checkboxes)

  • Sports
  • Music
  • Theater

Then the followup question: 

What topics are you specifically interested in? (also checkboxes)

If you chose Sports only, you see: 

  • Football 
  • Baseball 
  • Soccer

If you chose Music only, you see: 

  • Rock
  • Opera
  • Jazz

If you chose Sports and Music, you see: 

  • Football
  • Baseball
  • Soccer
  • Rock
  • Opera
  • Jazz

Again, not a real example, but the concept is basically giving people a short list of broad categories to choose from, and then only as many specific topics as are relevant to them, to keep the form only as long as it needs to be. 

SanfordWhiteman
Level 10 - Community Moderator

I'm thinking yes, with a regex matching on the semicolon-delimited string you get from Checkboxes ("sports;theater"). But haven't tried this exact method.