We have child object "Auto" on Account object.There is a text field Auto Number on Auto object.

We need to prevent reps from entering same number for this field for different records for same account. Auto number can be same for different accounts but cannot be same on one account

I can write validation rule to prevent entering same number for this field but how do we prevent it on same account

2 Answers 2


You can do it using standard salesforce.

Create a field on Auto Object(AutoUniqueField__C , type=Text , Unique Case Sensetive , size 30)

Now create a workflow rule on create for auto, that populates AutoUniqueField__C as Account__C + Name.

Thats it, done.

if someone tries to create a new record with the Same name for same account, the Unique field constraint will break and will be shown an error.

  • On the workflow rule, put whatever the API name is of the Auto Number text field (which I understand to be the designated number for the Auto, not an auto-number field). It's not clear from the original question that the Auto Number field is the Name field. But this is a really clever solution! May 21, 2019 at 21:50
  • I created workflow and got a unique value but how would you write this in validation rule that applies for all accounts?
    – Admin_BA
    May 21, 2019 at 22:35
  • Auto Number is custom text field
    – Admin_BA
    May 21, 2019 at 22:36
  • 1
    You don't need a validation rule. Unique field and workflow field update would be just enough May 21, 2019 at 22:37
  • @PranayJaiswal can you elaborate why this works? This was a great answer! May 22, 2019 at 1:13

I don't think this can be done with a validation rule, you need to do this with a before insert and before update trigger.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .