Hello,
Thanks in advance! I have an issue with the script i wrote, to implement business requirement, editor shows that al checks passed and to me script seems fine, however im not a developer.
Use case:
1. issue is created via API (text box that will determine the mapping is populated 100% of the times)
2. We need to set value in Single select list based on the input form the text field (example, if text says "Hello" set destination list value to "greeting"
Seemed pretty simple, but for some reason values are not set, even though logs show successful execution.
Any help will be greatly appreciated, we are trying to scale this solution.
PS. values in the destination field exist in Jira and field is placed on all appropriate screens
Please find script below:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dataclassCF = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Data Class"}
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Data Class test"}
def issue = event.issue as Issue
def issueService = ComponentAccessor.getIssueService()
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issueToUpdate = (MutableIssue) issue;
log.error(event.issue.getCustomFieldValue(dataclassCF).toString().contains("New Data Class"))
if (event.issue.getCustomFieldValue(dataclassCF).toString().toLowerCase().contains("allergies and intolerances")) {
issueToUpdate.setCustomFieldValue(tgtField, "1")
} else if (event.issue.getCustomFieldValue(dataclassCF).toString().toLowerCase().contains("assessment and plan of treatment")) {
issueToUpdate.setCustomFieldValue(tgtField, "2")
}