Hello,
I'm trying to write a script in order to set a custom field. I've put in a post function under create transition. Here is the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def multiGroupCf = customFieldManager.getCustomFieldObjectByName("Demo-Π.Σ.Κ.Ε. Assignable Groups") //multigroup picker custom field
def group1 = groupManager.getGroup("EYKE Group") //jira group
def group2 = groupManager.getGroup("Group_Epilogi_Proistamenon") //jira group
def group3 = groupManager.getGroup("ISO - Security Officers") //jira group
def groupList = [group1, group2, group3]
issue.setCustomFieldValue(multiGroupCf, groupList)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
The problem is that when I create a new issue I receive the following error:
We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.
It seems like I can't access the current issue.
Do have any idea about how to solve the problem?
Thanks
Two things, although I'm not sure it's either of them:
In a post-function, you do not need to use updateIssue - you're already in the middle of creating. So I would try removing the last line and moving the function up before "create issue initially"
I'm not sure the custom field accepts an array as a value, I think it might need a collection
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you using a Scriptrunner postfunction?
Check the position of your postfunction.
It needs to be AFTER the System Postfunction "Creates the issue originally".
And preferrably before the reindexing Postfunction, so that the new values will be indexed along.
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.