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
sonali  vermasonali verma 

Validation rule not firing

Hello friends

I do not want user to enter duplicate account names. 
I created a validation rule ,  error formula : OR(ISNEW(),ISCHANGED( Name ))

But when I create a new Account it shows account already exists.

Also I did the above requirement using a workflow rule:

a) I created a custom field called dup_accnames (text) and made it unique. 

b) In workflow rule ,Rule criteria :  formula evaluates to true

OR(ISNEW(),(  Name != PRIORVALUE( Name )), true, false)

c) Field update : dup_accnames 

But In both the cases its not working

Can any one tell me where I am going wrong:?
One of my colleague told me to go with workflow rule but I am not sure why we even require a field update?


Regards
sonali 


 
Gajanan D BhadGajanan D Bhad
Hello Sonali,

    First create a field of type text and unique.
    And then write a workflow on account to update that new field with Account Name Field.
    Criteria shoule be "Every time edited and created".
    
    I think there is no need to write a validation rule for that.

   I hope it helps you.

Thanks,
Gajanan   
surasura
your  formula checks whether Accounts name has been changed but not whether it is  duplicate

try setting up your WF as below

User-added image

set your field update as below 

User-added image
make sure to acctivate your workflow rule 
 
SarfarajSarfaraj
@Sonali,

Gajanan already provided you the solution you need. Let me clarify why you need this field update. Reason is that Account name field is a standard field and is not unique. Also you cannot make this field unique by any configuration. The most widely used solution to this problem is to create another field in Account object, make it unique, required and always copy value of Account Name to this field. If for any record Account Name repeats this new field will generate the error.

As I can see you already have created a field dup_accnames. Make sure this is marked as unique and required. Also after creating this field, make sure you copy value from field Account Name to this new field dup_accnames for all account records. If you do not enforse this the validation will not work for old recods. I strongly recomend making this a required field.

Regarding the workflow, entry criteria for the workflow should be this,
OR(ISNEW(), (Name != PRIORVALUE( Name )))

It should run "Every time edited and created".

Add one action of type Field update to copy value from Account Name to dup_accnames.

--Akram
Sunil PalSunil Pal
HI Sonali,

I think the Sura and akram has explained everything in a better way. It will solve your problem regarding the duplication of Account Name records.

Thanks 
Sunil