Validate the Sub-grid record count in AdxStudio Portal / Dynamics Portal

Happy Evening šŸ™‚

One of the interesting scenario is to do validation in Portal Sub-Grid based on the record count.

Initially i thought that we could do using the JavaScript. But it’s not giving consistent record count.

Snippet which i used for getting thatĀ $(".table tr").length

Record counts which i got while doing testing are

  1. Grid is empty – 10
  2. Grid is empty – 0 when the form refreshed
  3. Grid with more pages – 10 + number of records in the current page
  4. Grid with one page – gives correct record count

It’s so strange and not consistent.Ā  Then we used plugin to validate the record.

Steps to follow in plugin validation

  1. Validate the plugin context has the N:N relationship
  2. Get the Primary Entity Id
  3. Create query expression for secondary entity
  4. Query the link Entity by relationship name
  5. Filter the related entity by primaryentity id
  6. Execute the query
  7. Get the record count and validate
  8. Register the assembly
  9. Register the step as global plugin, associate message and Post operation.
  10. Validation works perfectly in Post operation.

Here is the snap of the code which helps to do the stuff

 

I hope it help the user at some point. Let me know if you have any other way of validating the Sub-Grid.

If you need any help on Dynamics project and training, reach out to me. I am happy to assist all the time.

Do connect with me onĀ LinkedInĀ and follow this blog to know more about Dynamics and its related stuffs

Happy to connect with you all through blogging. Do share me your feedback, It helps to improve the content.

2 thoughts on “Validate the Sub-grid record count in AdxStudio Portal / Dynamics Portal

  1. Hi Maniraj, thank you for this post, I’m new to Dynamics portal. Was just wondering if this would work still for Dynamics 365 Power Apps Portal and how do you register a plugin on Dynamics portal? Much appreciated.

    1. Hi Sonia,
      Thanks for your comment. Apologies for the late reply.

      The PowerApps portal uses Dynamics 365 CRM/Power Apps as a backend. We couldn’t do client-side validation in the portal in the above logic, so I have implemented server-side validation (Plugin). Would you please follow the CRM plugin registration process?

      You need to register the plugin against the Primary Entity/Table and validate the relationship with the sub-grid.

      Would you please let me know if you need help?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.