Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Model driven - App OnLoad event to check for a custom code

(0) ShareShare
ReportReport
Posted on by 899

Hello,

I have my own custom model-driven app that requires our standard roles to be accessed.

On top of the role, I would like to add another security layer managed from our developer environment which is the same concept as licensing for CRM modules.

For example, if you have been assigned to the standard role that is required to access the app and you don't have a certain license assigned to you. It should not allow you to access the app even if you have a standard role or you are a system administrator. That will be managed from our development environment.

The following excel table is similar to our development environment table:

pastedimage1674066306031v1.png

Simply, User 1 has the standard role assigned but does not have a license meaning if user 1-> plays the model-driven-> on the landing page it should block him from accessing it and he should contact us to assign him a license.

pastedimage1674066355893v2.png

This is very similar to the following:

https://learn.microsoft.com/en-us/troubleshoot/dynamics-365/sales/error-when-accessing-app-module#resolution

https://xrmtricks.com/2021/05/07/how-to-run-javascript-code-when-loading-a-model-driven-app/

My questions are below:

  1. 1. Can we write a custom code to the OnLoad event of the application (NOT THE FORM) after playing the app or signing in check if the user has a license in our environment and we can decide if we allow him to access it or not?
  2. 2. I know that we can add a code onLoad event of the form but the landing page of our application is not a form it is the Dashboard screen meaning a page.
  3. 3. If the user does not have a license assigned can we block him from clicking on the site map and navigating and show him that he needs to have a license?

The main goal is to restrict access to the model-driven app using a custom code when the app is opened if the user does not have a valid license other than the security role assigned.

Any help is greatly appreciated.

Best regards,

  • EBMRay Profile Picture
    899 on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hello Bipin Kumar ,

    Have you had the change to check my reply?

    Best regards,

    EBMRay

  • EBMRay Profile Picture
    899 on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hello Bipin Kumar ,

    I am still wondering how the plugin will be triggered to check the logic if they will not be able to see the model-drive app or play the app from the list?

    We should trigger the plugin on load of the app and then we perform the logic to check if we should prevent or allow access to it.

    Please let me know how we should handle it.

    Best regards,

    EBMRay

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hi,

    Yes, appmodule is the entity name for model driven app.

    They will not see the model driven apps when they try to choose model driven app from app list.

    You may have to try and see how it works as I have not implemented this on my instance

  • EBMRay Profile Picture
    899 on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hello Abdul Wahab 

    I thought about this one. As a result of this, we have system administrators assigned this role, which should also be included in the licensing process, so if they don't have a license assigned, the app should be blocked.

    How would it work if we revoked the system admin user from them and they are global admins on the tenant? How would this outcome work? It will block them from accessing or it will allow them to access?

    Awaiting your response.

    Best regards,

  • EBMRay Profile Picture
    899 on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hello Bipin Kumar ,

    How will the plugin be triggered? Is it possible to trigger it whenever the app is opened?

    On which message specifically shall we register it based on the below documentation?

    learn.microsoft.com/.../appmodule

    Could you provide a small example?

    Awaiting your response.

    Best regards,

  • Suggested answer
    Abdul Wahab Profile Picture
    12,085 Moderator on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hi EBMRay,

    Hope you are doing well. How about a Power Automate that will run on a daily basis to validate users? If the licence is not assigned to the user then remove the user's security role so that the app is no longer accessible to him. Making sense?

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Model driven - App OnLoad event to check for a custom code

    Hi,

    How about writting plugin on retrieve multiple message on Model driven app entity to check the logged in user and license and based on this remove model driven app from the result ...

    learn.microsoft.com/.../modify-query-preoperation-stage

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 671 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 167 Super User 2025 Season 1

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 138 Most Valuable Professional

Product updates

Dynamics 365 release plans