I am trying to find the best method, that will work both in classic and lightning, to prevent a user from creating a more than 1 child record from a parent object; e.g pressing 'New' on a related list.

  1. Validation Rule / Triggers : These occur after the user presses 'Save'.. so I dont like this because it would mean the user has already spent time filling out details for the child record.
  2. Javascript button: Detail page button to redirect to new child record only if a rollup summary field returns 0 ... but javascript buttons are not supported in lightning.

I think the best solution would seem to be a detail page button to a custom visualforce page with custom controller to handle redirect to the existing child record or show a page with an error message and ask wher they'd like to be redirected.

  • Are the objects master-detail or lookup?
    – David Reed
    Aug 30, 2018 at 13:33
  • This is a master - detail relationship
    – user59760
    Aug 30, 2018 at 13:35
  • 1
    This doesn't seem possible without custom development. Problems don't end there; if you are using both Lightning and Classic in tandem then you would need to develop two solutions. Your best bet is option#1, however, you could optimize it by using quick actions, so only include required field on the quick action layout, and the user can later fill remaining fields if the record is valid.
    – Mahmood
    Aug 30, 2018 at 13:51

1 Answer 1


If you are creating child record from parent record's detail page then create a recordtype on the parent object and create a separate page layout where you can remove the New button of Child object's related list. Map this recordtype with the page layout.

When you create a child record then update the recordtype of Parent record. This way, user will not see the New button in the Parent record's related list.

Also, put a validation rule, which is based on Child count which you have mentioned, just in case, if child record is created from API or data load.

This is most effective OOTB approach.

  • Yes I think this would work nicely if the child record had 1 record type to consider. This answers the original question but I should've been clearer in my original question, because in my case the child object has 3 record types, I only want 1 of the recordtypes to be limited to 1 record per parent record. The other 2 should remain open for further new children. Do you have any further thoughts on that aspect?
    – user59760
    Aug 30, 2018 at 14:19
  • 1
    This is very clever solution. Awesome!
    – javanoob
    Sep 1, 2018 at 1:27

You must log in to answer this question.

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