We are working on projects were issues can be created via email or by assignee in name of reporter. So we have situation that we need to be able set reporter value based on project role (as JIRA default reporter doesn't have filter possibility on this).
So I have created script for post-function on "Create issue" transition (using new option to not create groovy file, but putting code in field "inline script")
def componentManager = ComponentManager.getInstance() CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField reporter = customFieldManager.getCustomFieldObjectByName('Reporter'); if (issue.getCustomFieldValue(reporter) != null ){ def cf = issue.getCustomFieldValue(reporter).getDisplayName() issue.setReporterId(cf) } issue.store()
And so far so good, everything seems to work, issue is created, JIRA default field "Reporter" value is taken from custom field BUT...
on this transition we also are using "send custom email" and here we have trouble, because JIRA doesn't recognize "Reporter" email.
And strange this situation is because in this email what we are sending we have value " <% out << issue.reporter?.displayName %> " and here everything is fine and name is shown correctly.
So the question and HUGE problem here is - why JIRA doesn't recognize "Reporter" email?
You should be setting reporter to the name, not the displayName.
def cf = issue.getCustomFieldValue(reporter).name issue.setReporterId(cf)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also facing an issue with reporter condition.
where i need to check reporter of the issue before script add user into request participant field and i am getting error: please help to get it work...
thanks in advanced !!
2016-11-30 15:30:10,199 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2016-11-30 15:30:10,199 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: SS-915, actionId: 11, file: <inline script>
java.lang.NullPointerException
at com.atlassian.jira.issue.IssueImpl.getCustomFieldValue(IssueImpl.java:896)
at com.atlassian.jira.issue.Issue$getCustomFieldValue$1.call(Unknown Source)
at Script757.run(Script757.groovy:33)
And here is the script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager() def userManager = ComponentAccessor.getUserUtil() def requestParticipantsField = customFieldManager.getCustomFieldObject("customfield_17806") def getUsersAsArray = { def users = ["pravin.mori"] ArrayList<ApplicationUser> userList = new ArrayList<ApplicationUser>() users.each { def user = userManager.getUserByName(it) if(user) { userList.add(user) } } return userList } CustomField reporter = customFieldManager.getCustomFieldObjectByName('Reporter') if (issue.getCustomFieldValue(reporter) == "vivek.janjrukiya") { MutableIssue myIssue = issue ArrayList<ApplicationUser> applicationUsers = getUsersAsArray() myIssue.setCustomFieldValue(requestParticipantsField, applicationUsers) }
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.