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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Need logic to look at a subgrid and it needs to contain at least 1 record before form can be saved

(0) ShareShare
ReportReport
Posted on by 26

I have a form and in that form is a subgrid.  A request came in saying a user needs to add at least one record into this subgrid before the overall form can be saved.

How can I do this so that the logic looks at the subgrid and sees at lease one record in there and then allows the user to save the form?

Can this be done from a workflow or Business Rule or script?

I have the same question (0)
  • Verified answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi, 

    You need a JS code that will run when the form is saved. CRM currently supports asynchronous operations for the save event. You can take advantage of this feature to check if the grid contains data by executing a retrieveMultiple. If the result is empty then you cancel the save.

  • Verified answer
    Nya Profile Picture
    29,064 on at

    Hi,

    First of all, if the save action you mentioned means creation, the request cannot be achieved because the sub-grid records are based on a relationship between entities.

    If it means updating, you can try to achieve your request with a real-time workflow with importing Dynamics 365 Workflow Tools Solution.

    For example, update Account record only when there is at least one Contact in the Sub-grid.

    1. Import Dynamics 365 Workflow Tools Solution. There is a “Count Child Entity Record” feature which is not an OOTB method in workflow.
    2. Create a real-time workflow targeting at Account entity.

     pastedimage1628227942710v1.png

    1. Trigger the workflow before the record is updated. (Select all fields.)

     pastedimage1628227947375v2.png

    1. Get the count of the child records with the field in their relationship.

     pastedimage1628227952788v3.png

    1. Add a condition: When the count equals 0. The value can be found in the following location.

     pastedimage1628227973070v5.png

    1. Cancel the workflow. You can set the error message in “Set properties”

     pastedimage1628227978130v6.png

    After activating the workflow, when an account without related contacts is updated and the Save button is clicked, an error message will be shown and the updating will be terminated.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
11manish Profile Picture

11manish 172

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans