In framework/entity/ScreenEntities.xml,line:437
<view-entity entity-name="DbFormAndUserGroup" package="moqui.screen.form">
<member-entity entity-alias="DBFUG" entity-name="moqui.screen.form.DbFormUserGroup">
***<key-map field-name="formId"/>***</member-entity>
<member-entity entity-alias="USRGRP" entity-name="moqui.security.UserGroup" join-from-alias="DBFUG">
<key-map field-name="userGroupId"/></member-entity>
<alias-all entity-alias="USRGRP"/>
<alias name="formId" entity-alias="DBFUG"/>
</view-entity>
Does this line make sense?
1 Like
Do you have a specific question about the view entity there? In general it looks fine to me. Although I’m not sure what the *** part is
In my understanding, should it be like this:
<view-entity entity-name="DbFormAndUserGroup" package="moqui.screen.form">
<member-entity entity-alias="DBFUG" entity-name="moqui.screen.form.DbFormUserGroup">
</member-entity>
<member-entity entity-alias="USRGRP" entity-name="moqui.security.UserGroup" join-from-alias="DBFUG">
<key-map field-name="userGroupId"/></member-entity>
<alias-all entity-alias="USRGRP"/>
<alias name="formId" entity-alias="DBFUG"/>
</view-entity>
This content is unnecessary:
<key-map field-name="formId"/>
1 Like
Each key-map that you apply to a member entity will be used to map an existing field to a field specifically for the view entity. This is commonly used if there are multiple ids with the same name that need to be joined into the same view entity.
I would assume (but don’t know for sure) that the <key-map field-name="formId"/>
is implied because it is the primary key and that entity is the base entity used for the view entity.
<entity entity-name="DbFormUserGroup" package="moqui.screen.form" use="configuration">
<field name="formId" type="id" is-pk="true"/>
<!-- ... etc ... -->
</entity>
The main reason for the key-map is for if you have multiple fields from different entities that need to be joined in the flat structure the view entity is. For example if you join in multiple entities with a fromDate
you would need to have a partyFromDate
and a financialAccountFromDate
to prevent name collision.
1 Like