Skip to main content

Hi All,

 

We wish to implement a check on Contact Name that it should not contain certain specific strings.

For example :

"Test" irrespective of case(lower or upper) should not be allowed as a value in Lastname field of contact.

For ex. if LastName is "test123" or "123test" it should be allowed.

But, if Lastname is "xyz Test" or "xyz test" it should not be allowed.

Similarly, if lastname is "test xyz" or "Test xyz" it should not be allowed.

Similarly, if Lastname is " xyz Test xyz" or "xyz test xyz" it should not be allowed.

 

All in all, if the field contains the mentioned word strictly as a separate word irrespective of its case then it should not be allowed.

 

It would be great if you can suggest some thing on this.

 

P.S.

1. Contains function is tried in validation rule and it does not satisfy the use cases 

2. "Test" is just one dummy value there are many more words to be restriced.

2. Apex would be last option for this requirement.

3 件の回答
  1. 2022年3月28日 16:39

    Hi @CHANDRA KANT BAGHEL, 

     

    A Regex function in a Validation Rule is definitely an option, although I'm not sure if it is going to add much more value than a validation rule with a CONTAINS() function. 

     

    Does the following Validation Rule formula work for you?

     

    (

    IF(CONTAINS(LOWER(LastName),"test"),1,0)+

    IF(CONTAINS(LOWER(LastName),"othertext"),1,0)+

    IF(CONTAINS(LOWER(LastName),"rabbit"),1,0)

    )>0

     

    If you have loads of values to excluded, whether using Regex or not, you may have to split the values into separate validation rules, do something funny with a before save flow to make a record fail a validation rule after doing a check against a number of values... or probably more wise to move to Apex.  

     

    Thanks, Angus