Skip to main content

GenericMultiple

GenericMultiple

The "GenericMultiple" ViewTemplate is used to display and edit data from the "n" side of a 1:n entity relationship. It allows multiple datasets to be shown in a horizontal, column-based layout. Each row represents one dataset and includes defined fields. Additional datasets can be added dynamically via a plus ("+") button.

This ViewTemplate is especially suitable for use in Edit Views, where new entries need to be added interactively.

Overview

Functionality

  • Displays multiple datasets horizontally.
  • Enables editing of selected EntityFields for each dataset.
  • Supports dynamic creation of new datasets via "+" button.
tip

It is recommended to use GenericMultiple only in Edit Views to ensure a consistent and functional user experience.

Example

ViewTemplate: "MultipleEdit"
View: CommunicationMultiEdit_view
Context: Communication

This ViewTemplate is referenced in the context Organisation by the view OrganisationEdit_view.

Appearance in the Client

In the client, "MultipleEdit" appears when adding a new company dataset:

  1. Navigate to:
    Contact Management > Company
  2. Click the blue "Plus" button to add a new company.
  3. In the input form, the GenericMultiple ViewTemplate labeled "Communication" is shown.
  4. It allows selection of a communication medium (e.g., email) and entry of its value (e.g., info@adito.de).
  5. Additional media entries can be added via the "+" button next to the label.

GenericMultiple

Configuration
Example: "MultipleEdit"

In the "MultipleEdit" ViewTemplate of Communication_entity, the following configuration is set:

  • columns:
    • MEDIUM_ID
    • ADDR

This configuration defines which fields are shown per dataset.

The label of a GenericMultiple ViewTemplate is set via the property title. If this is not defined, the title property of the underlying Entity is used instead.

Step-by-step Example: Assigning Multiple Persons to a Campaign

This example demonstrates how to implement a GenericMultiple ViewTemplate to support an action that assigns multiple Person datasets to a campaign.

Objective

Create an action that allows selecting and adding multiple persons to a campaign. A GenericMultiple ViewTemplate is used to enter the person data.

Required Components

You need two entities and contexts:

  1. One Entity to handle the data input (via the ViewTemplate)
  2. One Entity to save the data (insert persons as participants)

1. Entity Controlling the ViewTemplate

EntityFields

  • UID
  • CONTACT_ID

Consumer

  • Consumer: Persons
  • Provider: Contacts
  • Target Entity: Person

RecordContainer

  • Type: jDito
  • Configuration:
    • recordFieldMappings:
      • Add field UID
    • jDitoRecordAlias: Data_alias
    • contentProcess: Ensures proper result generation during save
if(vars.exists("$local.idvalues") && vars.get("$local.idvalues")) {
result.object([vars.get("$local.idvalues")]);
}

The onInsert process must not be empty. You must return a string, even if unused, to avoid runtime errors.

  • Field: CONTACT_ID
  • Consumer: Persons

displayValueProcess:

result.string(ContactUtils.getTitleByPersonId(vars.get("§field.CONTACT_ID")));

View Setup

  • Create a View with a GenericMultiple ViewTemplate.
  • Configure property columns with field: CONTACT_ID.

2. Entity Responsible for Saving

Consumer

  • Name: Participants
  • state: EDITABLE

Parameters

  • CampaignId_param: Contains the campaign's ID, passed from the calling action.

RecordContainer

  • Type: datalessRecordContainer
  • Alias: Data_alias

Action: addToCampaign

  • onActionProcess:
var participants = vars.get("$field.Participants.insertedRows");
var campaignId = vars.get("$param.CampaignId_param");
var inserts = [];
var table = "CAMPAIGNPARTICIPANT";
var cols = [
"CAMPAIGNPARTICIPANTID",
"CONTACT_ID",
"CAMPAIGN_ID",
"USER_NEW",
"DATE_NEW"
];

participants.forEach(function(oneParticipant) {
let contactId = oneParticipant["CONTACT_ID"];
inserts.push([
table,
cols,
null,
[
util.getNewUUID(),
contactId,
campaignId,
vars.get("$sys.user"),
vars.get("$sys.date")
]
]);
});

db.inserts(inserts);

View Assignment

  • Add the previously created GenericMultiple View (referenced by the "Participants" consumer) via "Add reference to existing View".

Example with a Single Entity

The GenericMultiple ViewTemplate can also be implemented using only one Entity.

Example

In the xRM project, a relevant implementation can be found in the context `VisitRecommendationNewVisitplanEntry .

Configuration Highlights

The Entity contains two RecordContainers.

It uses a Consumer VisitRecWithNoTimes that is connected to the Provider VisitTimes of the same Entity.

This demonstrates a more advanced but valid use case for GenericMultiple within a single-Entity setup.