Hello,
I'm currently creating a prototype to evaluate JIRA and ScriptRunner, and have some issues I need to learn about.
1- How do I set a "number field" to display values based on another field's value based on the condition when updating an issue.
here field A and field B are number fields.
If field A > 0 & Field B <0
then field C = yes
2- Also ,
If field A < 0 & Field B >0
then field C = no
Thank you,
Hi @Sam Here you go:
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField cfA = customFieldManager.getCustomFieldObject(12456L) //Your number CustomField A
CustomField cfB = customFieldManager.getCustomFieldObject(12456L) //Your number CustomField B
CustomField cfC = customFieldManager.getCustomFieldObject(12456L) //Your number CustomField C
Double aValue = cfA.getValue(issue) as Double
Double bValue = cfB.getValue(issue) as Double
if (aValue > 0 && bValue < 0) {
issue.setCustomFieldValue(cfC, "yes")
} else if (aValue < 0 && bValue > 0) {
issue.setCustomFieldValue(cfC, "no")
}
ComponentAccessor.getIssueManager().updateIssue(
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(),
issue,
EventDispatchOption.ISSUE_UPDATED,
false
)
I'm assumed that your CustomField "C" is a Text Field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.