web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Business Rules on Relationship Entity

(0) ShareShare
ReportReport
Posted on by

Hi all,

what is the best way to add business rules when we create or modify relationship between entities?

In my use case, I have N:N relationship between Entity A and Entity B.

Users can relate only some Entity B records: only records that have the EndDate (custom field) >= current timestamp.

One solution is to add filter on Entity B view, but when users are adding the related entity they can switch view and use a non filtered view. In this way they can relate all B records.

1. Can we define a busienss rules on the Relationship Entity, and show an error message when a user try to create a relation on both sides?

2. Possible work-around: Is there a way to show only the filtered view when the user define the relationship?

Thanks in advance 

I have the same question (0)
  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi Andrea,

    Business rules is only available on entity forms. If you want to filter the entity view, it is not possible by business rules.

    If you want to filter the look up view, you could set some configurations.

    Open the form editor, open the lookup field properties.

    Close the "View Selector" and set your custom filter view as default view. Then users will be only able to choose records in your custom view in look up field.

    pastedimage1597720036897v1.png

    Regards,

    Leo

  • Community Member Profile Picture
    on at

    Hi Leo,

    thanks for your response.

    I was able to set the configuration only for 1:N relationship, opening the lookup field properties.

    In this case I have N:N relationship and a sub-grid inside my form. In the subgrid properties, I configure only one view, and is OK. But When I click the Add button on the subgrid, in the "Search Records" form, I can click "All records" and then switch on all the views related to Entity B.

    I was not able to find and configure the "Search Record", I use a default N:N relationship with autogenerated Relationship Entity.

    Is possible to customize the search adding filters and configure only one filtered view when I click on "All records"?

    4744.subgrid.PNG

    search-record.PNG

    Thanks

  • LeoAlt Profile Picture
    16,331 Moderator on at

    Hi partner,

    If you are adding the new record in "Related" section, it is by design.

    There is already an idea about this.

    https://experience.dynamics.com/ideas/idea/?ideaid=81cdcbf4-dffc-e911-b862-0003ff68954d

    Regards,

    Leo

  • Roma Gupta Profile Picture
    725 on at

    Hi Andrea

    Did you manage to solve this?

    After reading responses, I think what you need would require custom script. But I couldn't understand the need of your requirement?

    Regards

    Roma

  • Community Member Profile Picture
    on at

    Hi Roma,

    I was not able to completely solve the problem. I have tried with manual N:N relation, creating a manual Relationship Entity and I was able to add my filter and to show only one View when a user link a Releted Entity. This works only if user click on + button of the subgrid. If a user select 3 dots of a subgrid and click on "Add Elements.." he is able to insert every kind of records, because he can see all records and all views.

    2627.Capture.PNG

    The requirement is to allow relationship only with some records of Entity B, based on some field value.

    For example, a user can link to Entity A, only Entity B records with EndDate >= Datetime.Now

     I thought to reach this result configuring some business rules and getting a managed error or filtering the list of possible records in subgrid. But using the default N:N relationship is not possible; using a manual N:N relationship a user can insert all records by clicking on the "Add Elements".

    Do you have other solutions?

    Thanks

    Andrea

  • Suggested answer
    Roma Gupta Profile Picture
    725 on at

    Hi Andre

    Update the settings of the sub grid to below. Default view needs the view created as per criteria. 

    66104.Capture.PNG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans