Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How add labels to 'IssueInputParameters'

limon4ick July 29, 2016

Hi!

I create new Issue with usage IssueInputParameters

IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
issueInputParameters.setSummary(...);
issueInputParameters.setDescription(...);
...
 
IssueService.CreateValidationResult result = issueService.validateCreate(user, issueInputParameters);
...
issueService.create(user, result);

 

But I cannot understand how I can add to issue 'Labels' , 'Attachments' and 'Linked Issues'.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2016

You need to use other services to do that after the issue is created. For example to add a label use the LabelManager. There is also AttachmentManager and IssueLinkManager. Implementations of these services can be retrieved via the ComponentAccessor.

limon4ick July 31, 2016

Thanks! It.s more preferably variant

1 vote
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2016

Hi

You should treat labels and attachments (I am not sure for linked issues) therefore use addCustomFieldValue

regards

limon4ick July 29, 2016

Thanks!

Labels exactly work, other fields will try later.

0 votes
StephenG March 27, 2017

Here's a code sample:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager

Followed by:

LabelManager labelManager = ComponentAccessor.getComponent(LabelManager.class)
labelManager.addLabel(user, issue.id, label, false)
0 votes
Stefan F_ September 12, 2016

This worked for me (with a custom field "Customer" that contains labels):

IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();

...

Set<Label> customers  = (Set<Label>) customFieldCustomer.getValue(issue);
String[] arrayCustomers = customers.stream().map(Label::getLabel).collect(Collectors.toList()).toArray(new String[customers.size()]); issueInputParameters.addCustomFieldValue(customFieldCustomer.getId(), arrayCustomers);
issueInputParameters.setSkipScreenCheck(true); // https://stackoverflow.com/a/32328015
CreateValidationResult createValidationResult = issueService.validateSubTaskCreate(user.getDirectoryUser(),issue.getId(), issueInputParameters); if (createValidationResult.isValid()) { IssueResult createResult = issueService.create(user.getDirectoryUser(), createValidationResult); if (createResult.isValid()) {  ... } }

 

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events