Prevent New Child Record without triggers

Prevent New Child Record without triggers



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.



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 at 13:33





This is a master - detail relationship
– user59760
Aug 30 at 13:35





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 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.


New



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.


New



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 at 14:19





This is very clever solution. Awesome!
– javanoob
Sep 1 at 1:27



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)