Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Suggested answer

Javascript validation for subgrid in a secondary tab

Posted on by 60

Hello Community,

I have a lead form that has multiple tabs, when I qualify a lead I trigger some javascript to run some validation on some field and verify that the information's are filled.

One of the things that I am trying to achieve, is to be able to see whether a user has created a record in a particular subgrid, by counting the number of records in the following way 

formContext.getControl("grid").getGrid().getTotalRecordCount()

The problem that I am facing is that the result of this will always be 0 if I am not on the specific tab where the grid is because the grid has not loaded. I think this happens because dynamics loads data lazily.

How do I count the number of items in the subgrid without navigating to the specific tab, and select qualify?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript validation for subgrid in a secondary tab

    Hi M.Barimah,

    If your view in the Subgrid is unchangeable, you could directly query form the Dataverse by using retrieveMultipleRecords() methond(link:retrieveMultipleRecords (Client API reference) in model-driven apps - Power Apps | Microsoft Docs) with the same filter of your view.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans