Legacy Knowledge Base
Published Jun. 30, 2025

Is it possible to enforce that you cannot create/save a parent object until you have connected to it at least one child object?

Written By

Sorin Pop

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • steps :
    - Create Object called "news"
    - Create object called "News Attachments" 

    the requirement : 
    I cannot add new news without adding attachments , I need to prevent the user to add a new news without attachments . 

Environment

  • QR

Resolution

  • this is not possible in the out-of-the-box product. When you create a news object, first only the first layout tab will appear (where you can fill in the news object fields). After you save, then the relationship tab appears, where you can continue to edit the news object by adding attachment objects to it. There is even a warning about this, when you create the layout for the news object, see attached image.
     
    The article at https://learn.liferay.com/w/dxp/liferay-development/objects/creating-and-managing-objects/relationships/defining-object-relationships#making-relationship-fields-mandatory seems to describe something similar, but it's the other way around. That is, you can enforce that, when you create an attachment object, you need to provide a parent news object that it belongs to (otherwise you cannot save the attachment). But it's not possible the other way around: when you create a parent object entry, you can enforce that you create/link at least one child object entry to it. 
     

 

 

Did this article resolve your issue ?

Legacy Knowledge Base