While using the Automation for Jira Cloud, is it possible to get the key of the issue that was created in the very same automation?
Here's a screenshot of what I'm trying to implement. The issue is created perfectly - I just want to send the Key of the created issue over Slack/Teams/Email without using JQL/Lookup to fetch it.
selectedSuppliers is a list of all of the selected options from your multiselect, you need to use the 'it' variable that you get from your .each loop to assign a single value from this list to your new issue.
Try out this code, I did not directly test it but I made a few changes that I 'think' will fix the problems you mentioned:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
Issue issue = issue
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
int i = 0
//assuming this is a multiple select list custom field
def suppliers = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10201")
def selectedSuppliers = issue.getCustomFieldValue(suppliers)
def issueSummary = issue.summary
def issueDescription = issue.description
def issueReporter = issue.reporter
selectedSuppliers?.each {
def issueFactory = ComponentAccessor.getIssueFactory()
def issueManager = ComponentAccessor.getIssueManager()
def newIssue = issueFactory.cloneIssue(issue)
newIssue.setIssueTypeId("10101")
newIssue.setSummary(issueSummary)
newIssue.setDescription(issueSummary)
newIssue.setReporter(issueReporter)
newIssue.setCustomFieldValue(suppliers, it.toString())
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
issueManager.createIssueObject(currentUser, newIssueParams)
}
If I misunderstood your issue or if you have any other questions, please let me know. :)
Jenna
Hi Jenna,
Thanks for your answer, it is working now! :)
Moreover, do you have any clue on how could I set the security level based on this custom field value?
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.