mdhEntityThese options can be used if the values of a select widget are filled from the MDH. The widget is rendered using Select2.
Important: The schema properties minItems and enum must be set to 0 and [].
Property names
idProperty: ID property of the entity instance, will be saved if an item is selecteddisplayProperty: template to display an item, can use instance properties (example: "{firstName} {lastName}")searchProperty: property to use in Ajax search calls: /Entity?<searchProperty>=userinput*Multiple selection
multiple: boolean, if true, multiple items can be selectedMDH source
source: MDH entity name to the request instances of.source requires an empty "enum": [] element in the accorrding schema property!loadAllData: boolean, if true, the complete list of available MDH entity instances will be loaded at once, no Ajax calls will be made on typing. If false, a search will be performed on user input using source and searchPropertysortBy: property to sort the result onsortDirection: direction of the sorting (ASC or DESC)filter: object containing key:value mappings to filter the MDH entity instances onIndirect Instance Creation
Some MDH entities allow creation of new instances. These options specify how this is done.
indirect: Object that bundles all properties required to check and create indirect Entity Instances (example: check and create a Supplier for a selected BusinessPartner)
entityTarget: URL path to the indirect Entity (example: "Supplier")entityProperty: the property of the indirect Entity to build a filter with (example "businessPartnerId" would result in Supplier?businessPartnerId=BP-00001 if the value of this form element is BP-00001)copyFromProperty: the property of the Entity Instance to use as the value for a created indirect Entity Instance (example: "name" would copy the name property of a found BusinessPartner)copyToProperty: the property of the indirect Entity Instance to copy the value to (example: "name" would copy to the name property of the created Supplier)addToFormdata: the form element to append the ID of the indirect Entity Instance to (example: "md_creditorNoList" would append the Supplier ID to the form element md_creditorNoList)Can new items be added?
addable: boolean, if true, a new value can be entered by the user, if false, only existing values can be selectedcreateNewOverMDH: boolean, if true and a new value is entered by the user, a new instance will be direclty created on the MDH using a POST request. The GUI wil receive the ID of the created instance and save it in the formData. If false, a new value will be saved as entered.addableFieldName: If addable is true, this will be the property of the MDH instance the entered value will be used for.Simple Example
This configuration will render a Select2 widget that makes AJAX request to the MDH Entity /BusinessPartner?tenantNo=TN-00001&displayName=<userinput>. Only a single option can be selected. Adding a new Entity Instance is not possible.

{
"schema": {
"properties": {
"bd_partnerNo": {
"minItems": 0,
"type": "string",
"required": true,
"enum": []
},
}
},
"form": [
"bd_partnerNo"
],
"uiSchema": {
"bd_partnerNo": {
"widget": "mdhEntity",
"idProperty": "id",
"displayProperty": "{id} ({displayName})",
"searchProperty": "displayName",
"multiple": false,
"source": "BusinessPartner",
"filter":{
"tenantNo": "TN-00001"
}
}
},
"formData": {
"bd_partnerNo": "BP-1234"
}
}
Create new MDH Entity Instance
This configuration will render a Select2 widget that makes AJAX request to the MDH Entity /Employee?displayName=<userinput>. Multiple options can be selected. It is possible to enter the name of a new employee which will immediately be created on the MDH. The entered value will be set as the lastName property of the created Entity Instance.

{
"schema": {
"properties": {
"md_employeeNoList": {
"minItems": 0,
"type": "string",
"required": false,
"enum": []
},
}
},
"form": [
"md_employeeNoList"
],
"uiSchema": {
"md_employeeNoList": {
"widget": "mdhEntity",
"idProperty": "id",
"displayProperty": "{firstName} {lastName}",
"multiple": true,
"addable": true,
"createNewOverMDH": true,
"addableFieldName": "lastName",
"source": "Employee",
"loadAllData": false,
"searchProperty": "displayName"
}
},
"formData": {
"md_employeeNoList": ["EM-123", "EM-456", "EM-789"]
}
}
Allow new Value
This configuration will render a Select2 widget that makes AJAX request to the MDH Entity /Contact?displayName=<userinput>. Multiple options can be selected. It is possible to enter the name of a new contact which will be saved together with the id property of selected Entity Instances. A post processing step will create a new Entity Instance on the MDH. The entered value will be set as the lastName property of the created Entity Instance.
{
"schema": {
"properties": {
"md_contactNoList": {
"minItems": 0,
"type": "string",
"required": false,
"enum": []
},
}
},
"form": [
"md_contactNoList"
],
"uiSchema": {
"md_contactNoList": {
"widget": "mdhEntity",
"idProperty": "id",
"displayProperty": "{displayName} ({id})",
"multiple": true,
"addable": true,
"createNewOverMDH": false,
"addableFieldName": "lastName",
"source": "Contact",
"loadAllData": false,
"searchProperty": "displayName"
}
},
"formData": {
"md_contactNoList": ["CO-123", "CO-456", "CO-789"]
}
}
Indirectly create new MDH instance
This configuration will render a Select2 widget that makes AJAX request to the MDH Entity /BusinessPartner?displayName=<userinput>. Only a single option can be selected.
For a SupplierInvoice that is assigned to a BusinessPartner, check if this BusinessPartner is a Supplier. If not, create a Supplier using the bd_partnerNo as the value of the businessPartnerId property.
{
"schema": {
"properties": {
"bd_partnerNo": {
"minItems": 0,
"type": "string",
"required": false,
"enum": []
},
}
},
"form": [
"bd_partnerNo"
],
"uiSchema": {
"bd_partnerNo": {
"widget": "mdhEntity",
"idProperty": "id",
"displayProperty": "{id} ({displayName})",
"multiple": false,
"searchProperty": "displayName",
"source": "BusinessPartner",
"loadAllData": false,
"indirect": {
"entityTarget": "Supplier",
"entityProperty": "businessPartnerId",
"copyFromProperty": "name",
"copyToProperty": "name",
"addToFormdata": "md_creditorNoList"
}
}
}
}