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
Siva AdminSiva Admin 

Add error while entering record with some name ending with, say for example, 'Text' eg: 'JohnText'

Hello all, I'm newly learning SF working on this requirement. It follows like this:

While inserting a text value as 'someName' ended with 'text' ex: 'JohnText' On Account Object it should through an error.
While updating, the same text value as 'JohnText' should accept it.
How to achive this? Kindly help. 
VineetKumarVineetKumar
Write a validation rule on this field, to control this behaviour.

 
Siva AdminSiva Admin
Thanks for your reply. Can you tell me how we can do that using validation?
GauravGargGauravGarg
Hi Siva,

You can implement above scenario via two possible and simple approach:
1. Make Account Last Name field as unique. (setup --> Account --> Fields --> edit Last Name and make it unique)
2. Add validation rule on Account field, to make it unique.

Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
Vishal_GuptaVishal_Gupta
Hi Siva,

In Validation rule just put below code in error condition formula and your desired error message in error message textbox of validation rule :

User-added image

Let me know if you need more input from myside.

Thanks,
Vishal
VineetKumarVineetKumar
Validation would look something like below :
ISNEW() && RIGHT( <Field_Name>, 4) <> "TEXT"
Replace <Field_Name> with the API name of the field, 
Replace TEXT with the required text that you want to match
Replace the number 4 with the length of that text.