I am looking for some assistance in a Groovy script in Scriptrunner that will add a value from the system "Priority" field to a value from a custom field (single choice) and populate the total into a 3rd field that is my end-point. I am able to do this with the custom field, but I am having major issues trying to pull a single numeric value from the "Priority" field. My end result should be very simple, but I have spent hours trying to make sense of the Priority field. All I need to do is; A + B = C...which in this case is;
A. "Client Health"[custom field] with 4 single pick choices
B. A value from the system "Priority" field, but based on a reverse numbering criteria
C. Resulting single digit "Churn Risk" field with A + B
Here is my script so far. I can get A working just fine (populates C with A+A for example). It is B that I cannot get to work. I did have it doing some form of calculation at one point, but there were 4 leading numbers in there (so 5 was showing as "10404").
import java.lang.Integer
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.priority.Priority
def customFieldManager = ComponentAccessor.customFieldManager
def clientHealth = customFieldManager.getCustomFieldObjectsByName('Client Health').first()
def clientHealthValue = issue.getCustomFieldValue(clientHealth)
def clientHealthValueMap = ['0 - Black':0, '1 - Green':1, '3 - Yellow':3, '5 - Red':5] as Map<String, Long>
def reporterPriority = issue.priority.id
def priorityLevelValueMap = ['P1 - Critical':4, 'P2 - High':3, 'P3 - Medium':2, 'P4 - Low':1] as Map<String, Long>
if (clientHealth) {
def option1 = clientHealthValueMap[clientHealthValue.toString()] as Long
def option2 = Integer.parseInt(issue.priority.id)
(option2 + option2)
}
else {
0
}
//Any help would be greatly appreciated!!!