Happy Evening 🙂
One of the interesting scenario is to do validation in Portal Sub-Grid based on the record count.
Snippet which i used for getting that
Record counts which i got while doing testing are
- Grid is empty – 10
- Grid is empty – 0 when the form refreshed
- Grid with more pages – 10 + number of records in the current page
- 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
- Validate the plugin context has the N:N relationship
- Get the Primary Entity Id
- Create query expression for secondary entity
- Query the link Entity by relationship name
- Filter the related entity by primaryentity id
- Execute the query
- Get the record count and validate
- Register the assembly
- Register the step as global plugin, associate message and Post operation.
- 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.