I found this method :
ComponentAccessor.getIssueManager().createIssueObject(user, issue);
whereas issue is the issue to be created.
So I have problems to create this issue, because Issue and MutableIssue are both interfaces.
You could do
MutableIssue issueNew = new MutableIssue{...} // implement about 100 Methods :(
The other way would be with a map .
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
Map<String,Object> map = new HashMap<>();
map.put("Summary","My Summary");
// and all the other fields..
Issue createdIssue = ComponentAccessor.getIssueManager().createIssueObject(user,map);
I am not happy with all these approaches. For example I do not exactly know what key to put in the map. Is it the same as the label you see next to the fields in the ticket ?
Hello @Albert Cameron
you can try with issueFactory
import com.atlassian.jira.component.ComponentAccessor
def issueFactory = ComponentAccessor.getIssueFactory()
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserUtil()
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
MutableIssue newissue
newissue = issueFactory.getIssue()
//set values
newissue.setProjectObject(issue.projectObject)
newissue.setIssueTypeId(issue.getIssueTypeId())
newissue.setSummary(issue.summary)
newissue.setDescription(issue.getDescription())
newissue.reporter = issue.getReporter()
def newIssueCreated = issueManager.createIssueObject(currentUserObj, newissue)
I hope it helps.
Best regards.
IssueInputParameters issueIP = build.getIssueIP();
final IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(user, issueIP);
Yeah thanks.
There is also a class IssueInputParameters. Which also is usefull for setting CustomFields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If using issueFactory. Is there also a way to add customFields ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, there is.
After creating the issue, this new issue is a "normal mutable Issue".
So you can use the typical way to update it.
For example this.
https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-using-a-listener
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.