Excel Import Default Value


I’m trying to set default value for an association attribute while importing data using the below code.

    public Map<String, Object> getDefaultValues() {
        Map<String, Object> defaultValue = new HashMap<>();
        defaultValue.put("entity", selectedEntity);
        return defaultValue;

While importing the data, seems like this default value provided is not taken into account as i’m getting below error.

Validation failed:

  • entity: may not be null, provided value: ‘null’

Thanks for your help!!


@mario Kindly help here.

I’m struck because of this.

entity is an Association property of Asset Entity. And it is mandatory too. I give option to the choose the entity to the user. So the Assets in Excel file should be imported to the selected Entity.

To get this functionality I’m using getDefaultValues method as mentioned in the git documentation of the add on.

I debugged and found that view for this property is coming as null (I could see all the properties view is null), because of this, this property is not getting copied from srcEntity to dstEntity.

Below is the code in the addon which is copying the value from srcEntity to dstEntity.


Is there any config I should make for this property?

Thanks & Regards,


you are right. I think this is because of being a reference to another entity. It might be that this use-case I did not think of with the view: so you probably spotted a bug.

That being said, I would suggest using the DataImportAPI for doing it, because there I already had that use-case implemented in multiple projects. Here is the method that you need: https://github.com/mariodavid/cuba-component-data-import/blob/master/modules/core/src/de/diedavids/cuba/dataimport/DataImportAPI.java#L52.

Here is an example of how to use it:

            ImportExecution importExecution = dataImportAPI.importFromFile(
                    Collections.singletonMap("entity", selectedEntity),
                    entityImportView -> entityImportView.addManyToOneProperty("entity", ReferenceImportBehaviour.ERROR_ON_MISSING)

The third parameter is the default values map and the fourth parameter is a consumer for an entityImportView, which allows adding your entity to the import view.

It requires you to create a custom service and call the data import API programmatically.

I hope this helps.


Thanks @mario. It helped.