Skip to content

Instantly share code, notes, and snippets.

@jechlin
Created October 20, 2015 19:13
Show Gist options
  • Save jechlin/a638517606579f204b35 to your computer and use it in GitHub Desktop.
Save jechlin/a638517606579f204b35 to your computer and use it in GitHub Desktop.
// This was a request from a potential customer
// The requirements were that the price was entered as a number
// and the Third Party Relationship was chosen from a single select list
// then the Assignee is assigned automatically as part of a create issue transition post function
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger.getLogger("com.onresolve.jira.groovy").setLevel(Level.DEBUG)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def numberCf = customFieldManager.getCustomFieldObjectByName("Purchase Amount")
def selectCf = customFieldManager.getCustomFieldObjectByName("Relationship Type")
def gsmCf = customFieldManager.getCustomFieldObjectByName("GSM")
def purchaseAmount = issue.getCustomFieldValue(numberCf) as double
def thirdPartyRelationship = issue.getCustomFieldValue(selectCf)
def gsm = issue.getCustomFieldValue(gsmCf)
if (purchaseAmount < 5000) {
println "purchaseAmount ${purchaseAmount} is less than 5000"
issue.setAssigneeId('Admin') // Change user1 to the appropriate user in JIRA
} else {
if ((purchaseAmount >= 5000) && (purchaseAmount <= 10000)) {
if (thirdPartyRelationship == 'value A') {
issue.setAssigneeId('Admin') // Change user1 to the appropriate user in JIRA
} else {
issue.setAssigneeId("milind") // Change user2 to the appropriate user in JIRA
}
} else { // purchaseAmount > 10,000 and thirdPartyRelationship should be irrelevant
issue.setAssigneeId("milind") // Change user2 to the appropriate user in JIRA
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment