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'.
Community moderators have prevented the ability to post new answers.
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.
Hi
You should treat labels and attachments (I am not sure for linked issues) therefore use addCustomFieldValue
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()) { ... } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.