Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to associate a Component to an issue while creating issue using IssueInputParameters?

Dhruv Dixit February 4, 2020

How to associate an existing Component in Jira to an issue while creating the issue programatically using IssueInputParameters?

1 answer

1 accepted

0 votes
Answer accepted
Hana Kučerová
Community Champion
February 5, 2020

Hi @Dhruv Dixit ,

I believe you can use method setComponentIds(Long... componentIds).

Is it possible to share your code with me? Then I will be able to help you better.

Thank you.

Dhruv Dixit February 6, 2020

Hi @Hana Kučerová

Can we map the issue to an existing Component using Components names?

Is there some method like setComponentNames(String componentNames)?

If yes, could you please share the link to the documentation for the method?

 

Or else, could we somehow get the name of the component from Component ID?

Thanks in advance! 

Hana Kučerová
Community Champion
February 9, 2020

Hi @Dhruv Dixit ,

there no such method like setCompontNames.

But you can get component using it's name and then obtain component id from the found object:

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project

MutableIssue issue = issue
Project project = issue.getProjectObject()
ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager()
ProjectComponent component = projectComponentManager.findByComponentName(project.getId(), "Name")
if (component) {
    Long componentId = component.getId()
    // continue ...
}

If you please share your code, I can help you finish it.

Like Dhruv Dixit likes this
Dhruv Dixit February 10, 2020

Hi @Hana Kučerová ,

It has been solved by following your code.

Thanks for your help! :)

Suggest an answer

Log in or Sign up to answer