Populate User Types
Introduction
In your Mendix Pricing Plan there is a distinction between Internal and External Named Users of a Mendix App. This document helps you to set up your apps to meter External Users correctly. It describes a sample solution that can help you in External User classification for existing users of your apps.
Definitions
- Named User – an individual authorized by you to have access to your apps with unique login credentials, or an authorized external system that accesses or is accessed by your application.
- Internal User – a Named User who is an employee or contractor of your business.
- External User – a Named User who is not an employee or contractor of your business, and is designated as an External User in the Mendix Platform.
Background
Every Mendix app has a system module containing an entity UserReportInfo
. This entity has an attribute UserType
that is used to classify end-users as External or Internal Users. This attribute needs to be maintained for all existing and new end-users of a Mendix app. If this attribute is not set, the end-user is classified as an Internal User.
The Mendix Metering module relies on this attribute to ascertain the end-user type and report it back to us.
Approach
Outlined below is an example of a module that can be used to update UserType attribute. You will need to adapt the module logic for classifying your own internal and external end-users.
Domain model
In the example below, our aim is to update UserType attribute of UserReportInfo entity. However, the entity UserReportInfo
is protected in the System module and has no access rules. As a result, it cannot be exposed directly in the UI pages.
Therefore, the approach we take is to create a new non-persistable entity, UserTypeReport
, which we will populate based on the values of UserReportInfo
to show in the UI.
Populating UserType for Existing Users of an App
-
Create a microflow
User_RetrieveOrCreateUserReportInfo
which will ensure that aUserReportInfo
object exists for a givenUser
. -
Create a microflow
User_EvaluateAndSetUserType
which will populate theUserType
attribute on theUserReportInfo
entity for a givenUser
.In this example, we decide whether a user is
Internal
orExternal
based on the email address of the user. To do that, we need to retrieve the email address of each user from the database. Note that theSystem.User
entity itself does not have the email address. The email address is stored in specializations ofSystem.User
.Here, we show how to do it for two specializations of the
System.User
entity, namelyAdministration.Account
andMendixSSO.MendixSSOUser
. In theAdministration.Account
entity, the email is in attribute namedEmail
. And in theMendixSSO.MendixSSOUser
entity, it’s in an attribute namedEmailAddress
. Hence we need to use an Object Type Decision activity to split theSystem.User
intoAdministration.Account
andMendixSSO.MendixSSOUser
and then fetch the email address according to the name of the attribute.-
The logic to determine whether the end-user is internal or external is up to the developer. The example below returns
true
, to indicate that the user is internal, if the user has no email address, or if the domain for their email address ismendix.com
ormyorg.com
.
-
-
Create a new microflow
User_Correct_UserType
which will use the microflowsUser_RetrieveOrCreateUserReportInfo
andUser_EvaluateAndSetUserType
created above. In this microflow, we create and populate theUserTypeReport
entity and return a list of these entities at the end of the microflow. -
Create a page
UserTypeReport
with a DataGrid which uses the microflowUser_Correct_UserType
as its source. -
Add the page to the Navigation.
-
When you go to that page it will set the
UserType
as per your logic and show you the UserType report. -
The report can be exported into an Excel file.