1

I have a MD relation between two custom objects. So, the scenario is, right now I am able to create many child records (i.e. 1:M relation), but I have to restrict it to only one record creation (i.e. 1:1 relation) without changing the schema. Please help

1
  • you can create a before insert trigger on child object and check whether child record is already available or not for same parent. if one record already available then throw the error message.
    – Amol
    Commented Jan 22, 2018 at 6:00

1 Answer 1

2

As you are already using a master detail relationship. So here is one easy solution for you.

Create one Roll up summary field and do count of child record and add validation that count should not be greater then 1.

You don't need any apex code for this and if in future you want to change the limit just update the validation rule and if needed can deactivate that.

0

You must log in to answer this question.

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