App User Group (Related Entity) Mappings and Global Datasource User Groups
As detailed in the in the Reserved Entities section of this User Guide, the AppUser and AppUserGroup Entities are included as part of all new app designs.
The App User Group Entity is used to hold one or more of the User Groups that you define in the app design as part of Evoke's Access Control system.
This section provides a detailed explanation of how to Map the connection between the the AppUser and AppUserGroup Entities and also how to expose and configure the user groups set up in the app design for use in your completed running app.

Related Entities
The AppUser and AppUserGroup Entities are a good example of Related Entities. Two items/records/pieces of data that have a relationship.
Two records/items that have a 1-to-1 relationship are linked/joined together using Joins (SQL) or Local or remote keys (MultiValue), please see 1-to-1 related data.
Records that have a many-to-many relationship, such as the User groups and Users, have to be linked by Link Tables/Joins (SQL) or MultiValued Data (MultiValue).

There is a comprehensive review of Related Entities that explains the use of and configuration of these, in both SQL and MultiValue databases.


AppUserGroup Global DataSource
The AppUser and AppUserGroup Entities can also be mapped in relation of a Global DataSource. This section reviews exposing the User Groups and then mapping the AppUser and AppUserGroup Entities to this GlobalDataSource to that the Global DataSource can be used easily to populate which User Groups a User record is associated with in a running app. The screen on the right shows where this is used, as a design example, in the Evoke Example App.

First, you need to expose the Access Control User Groups as a Global Datasource by checking the box at the bottom of the Access Control User groups in the Apps section of Evoke.




This will create for you automatically a new Global Datasource with an initial selection of UserGroupsList.



Please see image of Global DataSources on the left with UserGroups datasource that was created when the checkbox in the AccessControlUserGroups screen was ticked.

Now you will need to set up the Data Mappings for the AppUserGroup as related data to the AppUser Entity. This is different for SQL and MultiValue Databases and so there are two descriptions below (please note: the Entities definition is the same regardless of the database. Please see image top right of this screen):
MultiValue Databases
The AppUserGroup Entity is just a standard MultiValued Attribute in AppUser object. The Data Mappings for this and an image of the actual data in the database appears below:

SQL Databases

The AppUserGroup Entity is associated/related to the AppUser Entity as a bi-directional Join.

The GroupName property in the AppUserGroups Entity will simply be an "AlphaNumeric" Property. You will need to add a new property to the AppUserGroup Entity called something like "AssociatedAppUser" which is an Entity related to the AppUser Entity.

The Data Mappings for this and an image of the actual data in the database appears below:
Please click on any of the images above to see a full size version of the screenshot image. In the AppUserGroup Mappings above, the Repository Object Name is simply the name you give the AppUserGroup Table in your SQL database. If you do not have a table you can use the "create" button to create the table. The AppUser Entity Related Data of UserGroups links to this table and joins the keys. he AppUserGroups Entity Related Data of AssociatedAppUser links to the AppUser table and joins the keys.



Using the exposed GlobalDataSource in your app design


As can be seen from the design screenshot on the right (which is from the Example App) you will need:
  • A Single Entity Segment to pick UserGroups from the Global Datasource (left segment) which is associated with a Datasource of one single "Classification" Entity Record to receive the selected UserGroup classification from the UserGroups GlobalDatasource and
  • A MultiEntity (table) Segment (right segment) to display all the groups associated with this user record.

The Template definition for the segment above is shown below left. This is a Lookup widget and the DataSource has been selected using the Build button as the GlobalDataSource "UserGroups".

When a User Group is picked you will need to perform a couple of ClickActions. In the Template (see image left) select the "Actions on option select" and add the following click actions:
CreateNewEntity in {AppUserDatsource}.current.UserGroups
AssignDatasourcepropertyValue from {UserGroupSelect}.Code to {AppUserDatasource}.current.UserGroups.current.GroupName








AppUserGroup as a Classification
As an alternative to a UserGroups GlobalDatasource, the User Group Classification, as seen in the image on the right, is used to set the user groups in the AppUserGroup entity.
The data in the Classification file will contain as many entries as you have user groups set up in Evoke so that these can be selected and used when updating user records.
The Entity definition of the AppUserGroups is slightly different if you are using Classifications and you must ensure that the "GroupName" property is a clasification

As can be seen on the left.