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 2

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?

  • Verified answer
    Nya Profile Picture
    Nya 29,058 on at
    RE: Need logic to look at a subgrid and it needs to contain at least 1 record before form can be saved

    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

  • Verified answer
    meelamri Profile Picture
    meelamri 13,212 User Group Leader on at
    RE: Need logic to look at a subgrid and it needs to contain at least 1 record before form can be saved

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,468 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,289 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans