How to skip the import of a cutom field?

Hello,

Is it possible to give to the users the opportunity to choose whether to import a custom field or not?

Thanks,

Petya

3 answers

1 accepted

Of course you can but you'll have to implement the whole logic by yourself. It's not that hard.

What you actually want is following:

  • you probably already have your own page for displaying custom fields so add a checkbox there (or other widget to mark what custom fields should be imported) - you can base your implementation on ImporterCustomFieldsPage
  • on this page store the data about selected fields in your ConfigurationBean object
  • when import is run getIssuesIterator will be called
  • if you use our IssueTransformer approach you'll need to add logic in your IssueTransformer class that will not set custom fields for given custom fields that were selected by the user to be ignored
  • the engine (DefaultJiraDataImporter) will import issues

The idea is simple what's in ExternalIssue object gets imported, if you don't put there custom fields data it will not get imported. So you need to control what gets put into your ExternalIssue in your IssueTransformer and you'll be fine.

Hi Pawel,

thank you for your suggestions. Here is what I did:

  • I added check boxes in the ImporterCustomFieldsPage velocity file;
  • I stored the selected fields in the ConfigBean;
  • Then, in order to have only selected fields for the mapping of the fields' values, I tried to take only the selected fields, but I failed because the SavannahValueMappingDefinitionsFactory is called very early. The reason was that piece of code in the AbstractProjectTransformer:
final ValueMappingHelper helper = configBean.getValueMappingHelper();
		if (helper.isWorkflowSchemeDefined()) {
			project.setWorkflowSchemeName(helper.getWorkflowSchemeName());
		}
    • So I commented that and now it is perfectly working.

However, if we want to use the workflows, I must add some changes in that code which I don't want, because then the merging with the new version would be complicated.

Have you noticed that AbstractConfigBean2 has initializeValueMappingHelper that you can override and put your own mapping helpers there. So while building your ValueMappingHelper you could already ignore fields that were not selected for import.

In ImporterFieldsMappingPage the valueMappingHelper is reinitialized so you don't need to worry it was used before. At least that's my impression from reading the code.

0 votes

What do you mean by "import" a custom field?

Are you importing from another system using the system importers? Drawing data in via a remote link? Something else?

Also, which system? I guessed Jira, but I've just noticed I could be absolutely wrong.

I develop a Savannah importer plugin as part of your JIM plugin. The thing I want to achieve is to add an opsion "Skip" to the drop-down menu on the "Set up custom fields" step. Choosing that the user could decide not to import values from that particular field. Can I do that?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in United States

Topic Tuesday: What's your favorite topic?

Good morning All, Our goal is to get you into the habit of while enjoying your favorite morning drink you are checking the NOVA "space" for topics and comments. Your input is really needed and...

67 views 4 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you