Hi All,
I have a script in place which checks, if a customfield (single-user-picker) is set or not.
...
...
def currentAppUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ASD: On behalf of")
def newReporter = issue.getCustomFieldValue(customField) as ApplicationUser
if (customField){
issue.setReporter(newReporter)
} else if (!customField){
log.info("Reach else tree")
issue.ReporterId = currentAppUser
}
ComponentAccessor.getIssueManager().updateIssue(issue.getReporter(), issue, EventDispatchOption.ISSUE_UPDATED, false)
The if condition works fine and the reporter will be replaced but unfortunately the else statement will never be executed. Instead of the currentAppUser the ticket creates "Anonymous" as a reporter.
Any suggestions?
Best,
Kristian
Hello,
Add logging and have a look what is the value for the customField is if this custom field is not set. You should see logs in the atlassian-jira.log file
def currentAppUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().name
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ASD: On behalf of")
def newReporter = issue.getCustomFieldValue(customField) as ApplicationUser
log.error("customField: ${customField.toString()}")
if (customField){
issue.setReporter(newReporter)
} else if (!customField){
log.info("Reach else tree")
issue.ReporterId = currentAppUser
}
ComponentAccessor.getIssueManager().updateIssue(issue.getReporter(), issue, EventDispatchOption.ISSUE_UPDATED, false)
,
Hi Alexey,
I found out thats wrong.
if (newReporter != null && customField != null) {
...
}
Its fixed and working perfectly.
Thanks anway.
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.