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.

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.

%d bloggers like this: