Import CSV file on a new CF Type doesn't work

Hi Guys,

I have created my own CF Type that extends AbstractMultiCFType<Project> where Project is a class created by me storing an active object entity called “Project” and having 2 attributes: ID and Name.
I’m storing inside the DB the name of this project when assigning this CF to the issue and saving it:
06
My problem is when I try to import the issue from CSV and try to update this field in JIRA, for example, put “Project9” inside my CSV under column CRM project and map it to this CF ==> after importing it, it didn’t update this CF by “Project9” inside the issue.
Did we have a way to customize the CSV importer or do I need to do a specific functionality at the level of my CF type?

Thanks in advance,
Rosy

Hello Guys,

Did anyone had the chance to check above?

Thanks,
Rosy

To my knowledge, there isn’t a way to extend the CSV import, you have an interface to control the export but not the import. If someone knows on a way to extend the import I would surely like to know as well :slight_smile:

As for the import, do you have any message in the logs? For sure, the import mechanism, once it has detected that you try to import a customfield will, at some point, call the “getSingularObjectFromString()” method from the CF type. You need to make sure that the string you put in the csv can be processed by that function. Might be worthwhile to put a breakpoint in there.

Hi @yvesriel,

Thanks for your reply:)
I just added implements ProjectImportableCustomField to my CF Type class and added
public ProjectCustomFieldImporter getProjectImporter() { return projectCustomFieldImporter; }
inside it and created a new class called CRMProjectCustomFieldImporter as follows:

public class CRMProjectCustomFieldImporter implements ProjectCustomFieldImporter {

    private static final Logger log = LoggerFactory.getLogger(CRMProjectCustomFieldImporter.class);
    private final ProjectService projectService;

    public CRMProjectCustomFieldImporter)
   {

   }

   @Override
    public MessageSet canMapImportValue(final ProjectImportMapper projectImportMapper, final ExternalCustomFieldValue customFieldValue, final FieldConfig fieldConfig, final I18nHelper i18n) {
        final String optionId = customFieldValue.getValue();
        if (optionId != null) {
           projectImportMapper.getCustomFieldOptionMapper().flagValueAsRequired(optionId);
        }
        return null;
    }

    @Override
    public MappedCustomFieldValue getMappedImportValue(final ProjectImportMapper projectImportMapper, final ExternalCustomFieldValue customFieldValue, final FieldConfig fieldConfig) {
        final String oldOptionId = customFieldValue.getValue();
        log.error("customFieldValue.getValue()" + customFieldValue.getValue());
        final String newOptionId = projectImportMapper.getCustomFieldOptionMapper().getMappedId(oldOptionId);
        return  new MappedCustomFieldValue(newOptionId);
    }
}

But, canMapImportValue and getMappedImportValue weren’t been called. Did I miss something?

thanks,
Rosy

Hi @rosy.salame,

This interface (ProjectCustomFieldImporter) doesn’t have anything to do with CSV import. It’s when you import a Jira project from a backup. The canMapImportValue and getMappedImportValue will be called during the project import so that you have a chance to tell if something is missing for the import and eventually provide the mapping from one system to the other.

1 Like

Thanks a lot @yvesriel for your replies. :slight_smile:
It seems that csv import cannot be extensible in JIRA, hopefully, we can in the future versions.
thanks a lot,
Rosy