Skip to content

[Bug]: Default Values not set properly when importing data #502

@SimonCremer

Description

@SimonCremer

Expected behavior

When importing new elements, the default values provided via default value generator should be set properly at first save operation.

Actual behavior

If you define a DataObject (myObject) with a mandatory input field (myField) that has a default value generator, a new object cannot be imported if myField is not mapped within the import configuration.
The ImportProcessingService (or some code which is called later) creates an object, saves it, and applies the default values in a second save operation.
The element is not created because the first operation fails with a Validation failed: Empty mandatory field message and therefore the default values will not be generated and the second save is not getting executed.
If I set the myField to be optional the import would work and the default value is applied. But thats not a valid workaround because the myField has to be mandatory.

Steps to reproduce

Create a DataObject myObject with a mandatory field myField. Create a default value generator which sets any value e.g. random string value, and use it in myField.
Create an DataObjectImporter which Imports data for myObject.
DataObjectImporter Setting:

  • DataSource you prefer (for example an excel file with some rows, no matter what content)
  • Resolver class: myObject
  • Element Loading Loading Strategy: No Loading
  • Element Creation Location Strategy: Static Path (or whatever you like)
  • Element Location Update: No Change
  • Element Publishing Publish Strategy: No Change, Publish New
  • Processing settings: whatever you like
  • Mapping: Empty (or add some more fields to myObject and import, doesn't matter)
  • Execution: Whatever you like

Start import execution.

This results in:

Processing DataRow 
Error processing element: Validation failed: Empty mandatory field [ myField ]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions