+ Start a Discussion
Priyanka LukosePriyanka Lukose 

Question about string comparison in validation rule

Hi All, I am new to Salesforce, doing some hands on exercise. How do we perform string comparison in validation rules, My requirement is there are 2 text fields on same web page,the text entering in A field should match the text entering in B. I tried usingNOT( Contains(A,B)).While entering inputs though both values in A and B matches it throws the err msg that I have kept in Validation rule
UC InnovationUC Innovation
Hi Priyanka,

I have two suggestions. Try using this to ensure that they are the same  otherwise A=race and B=racecar would pass your validation

NOT(A = B)

Also might want to make sure your validation rule is active.

Hope this helps!

AM
Prateek Singh SengarPrateek Singh Sengar
Hi priyanka,
Its straightforward comparison. For eg: I have two custom field Authorized_Signatory_First_Name__c and Authorized_Signatory_Last_Name__c  then i will use, you can use the same logic for standard fields or combination of standard and custom field.

Authorized_Signatory_First_Name__c  <>  Authorized_Signatory_Last_Name__c 
Priyanka LukosePriyanka Lukose
Hi...Thanks UC Innovation and Prateeksingh for Your response,

There are few more points I forgot to mention in the above question

Requiremant is 
2 textboxes B and A(Api name are B and A)
text entering in A should match B else throw an exception

B is actally of master-detail with  Object 1
was able to solve it using NOT(CONTAINS(A,object1__r.B) )

wondering Why the require err msg was not showing when i used below
NOT(CONTAINS(A,B__c) )

Please advice
UC InnovationUC Innovation
So A and B are not in the same object. Is B an object? Can you clarify the requirements?
Priyanka LukosePriyanka Lukose
Thanks ken tang for Your kind response..!

Object 1 has a field of datatype text
Object 2 has 2 fields A and B 
A text 
B of master detail relation ship with Object 1

Requirement is text in A and B should match else should throw an err message

I tried using But dint work
Not(contains(A,B_c))

Worked when changed formula to
NOT(Contains(A,object1__r.B))

My question is why the first formula dint work when I directly refer to the text B of same object