Expand my Community achievements bar.

SOLVED

Re: Validation Logic in custom forms

Avatar

Level 2

Hi,
I am trying to use Validation logic, but it is not working as expected. Here is my logic condition - User can write '2 Alpha' and '7 digit' hence in total it should be 9 without spaces.
I used this condition - 

IF(LEN({DE:Global | Global marketing campaign id})=9,"Please write '2 Alpha' '7 digit' and 'in total it should be 9' without spaces (eg-tmtpredict)")
 
Issue - It is not showing the error message as expected.DikshaGa1_0-1753191285637.png

 

1 Accepted Solution

Avatar

Correct answer by
Employee

Thanks for trying.
To make sure I understand your case correctly, your original problem was that you wanted the field value to have 9 characters, right? The formula you have right now is saying if the field's length is 9 characters, show the error message. Hence, if you type anything expect 9 length words, you will not see the error. If the use case is to allow words with the length of 9, and to not allow everything else, you need to revert the equation sign.

IF(LEN({DE:Global | Global marketing campaign id}) !9,"Please write '2 Alpha' '7 digit' and 'in total it should be 9' without spaces (eg-tmtpredict)")

View solution in original post

8 Replies

Avatar

Employee

Thanks for reaching out. 
Could you please retry with double equation signs?
IF(LEN({DE:Global | Global marketing campaign id}) =9,"Please write '2 Alpha' '7 digit' and 'in total it should be 9' without spaces (eg-tmtpredict)")

Avatar

Level 2

Thanks for reverting back.
This still not working, I applied a rule not to extend more than 9 words, the error message doesn't come up if I extend the limit. Here is the screenshot.

DikshaGa1_0-1753254747855.png

 

Avatar

Correct answer by
Employee

Thanks for trying.
To make sure I understand your case correctly, your original problem was that you wanted the field value to have 9 characters, right? The formula you have right now is saying if the field's length is 9 characters, show the error message. Hence, if you type anything expect 9 length words, you will not see the error. If the use case is to allow words with the length of 9, and to not allow everything else, you need to revert the equation sign.

IF(LEN({DE:Global | Global marketing campaign id}) !9,"Please write '2 Alpha' '7 digit' and 'in total it should be 9' without spaces (eg-tmtpredict)")

Avatar

Level 2

Thank you soo much, this one is working. One more question here, can we also convert this code to allow users to type only 2 Alphabets and only 7 numeric digits not more or less than this condition.

 

Regards,

Diksha g.

Avatar

Employee

The following expression should do it

IF(LEN({DE:Global | Global marketing campaign id}) != 9,"Please write '2 Alpha' '7 digit' and 'in total it should be 9' without spaces (eg-tmtpredict)",
IF(CONTAINS(0, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(1, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(2, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(3, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(4, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(5, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(6, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(7, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(8, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(CONTAINS(9, LEFT({DE:Global | Global marketing campaign id}, 2)), "Please start with '2 Alpha' without spaces (e.g.-ab)",
IF(LEN(NUMBER(SUBSTR({DE:Global | Global marketing campaign id}, 2))) != 7,"Please end with '7 digit' without spaces (e.g.-1234567)"
))))))))))))

Avatar

Level 2

Thank you soo much, it's working fine. 🙂

 

Regards,

Diksha G.

Avatar

Level 2

Hello @hnalbandyan could you please suggest how do I set up Validation Logic on a Text field for the Business Code to start with 2 Numbers followed by dash (XX-) only, otherwise Error?

Copilot is giving me REGEXP specific code only.

 

Thank you in advance.

Avatar

Former Community Member

One thing that often trips folks up is that validation logic does not work at all in Preview. In order to see your rule work, you have to save your changes and go find that form on a live record.