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...
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,216 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,060 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

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
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
Pallavi Phade Profile Picture

Pallavi Phade 32

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans