[SalesForce] Prevent duplicate account creation with custom error message

I have implemented workflow rule in maintaining unique name in the Account object everything is fine except that the error message that I'm getting I want to customize to give more meaningful error message then the below message, what do I need to do for that?

duplicate value found: Asset_Name_Dupe__c duplicates value on record
with id: 0019000000CZC83

:EDIT:

I have created Workflow rules by following this:

At first let us create a new Field on the Account object.

  1. Go to Setup | Customize | Accounts | Fields.
  2. Scroll down to Custom Fields & Relationships Section.
  3. Click New Field.
  4. Select the Type as: Text
  5. Name it as: Account Name Dupe Check[Account_Name_Dupe_Check, 255].
  6. Check the Option: Unique and also select: 'Treat "ABC" and "abc" as different values (case sensitive)'.
  7. Make it Visible for the appropriate Profiles. While you make them Visible also check the Option: 'Read Only'.
  8. You need not put them on the Page Layouts.

Now, let us create a new Workflow Rule[Account Dupe Check].

  1. Go to Setup | Create | Workflows & Approvals | Workflow Rules.
  2. Click New Rule.
  3. Select the Object: Account
  4. Evaluation Criteria: created and every time it's edited.
  5. Rule Criteria: formula evaluates to true.

OR(
ISNEW(),
ISCHANGED(Name)
)

  1. Save & Next.
  2. From under Immediate Actions, click Add Workflow Action to select 'Field Update'[Set the Account Name].
  3. Select the Field to Update: Account Name Dupe Check
  4. Select: Use a formula to set the new value
  5. In the formula box, type in 'Name'.
  6. Click Save.
  7. Click Done.
  8. Activate the WFR.

PS:
I do not have apex code yet.

Best Answer

No, you can't custom the error message for field uniqueness constraints.

However, you can prevent accounts with duplicate names and provide custom error messages using duplicate rules. Watch the Managing Duplicates Records with Duplicate Rules for a good tutorial/overview. As duplicate rules are designed for this particular purpose they have lots of features that would be useful for you (alert vs. report, block vs. allow, error messages, fuzzy matching).

For a specific implementation, see @nick_kahn's answer for how he set up his duplicate rule.

Related Topic