Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

help in conditional field based on two other fields


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,

1 answer

1 accepted

0 votes
Answer accepted

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")


 I'm assumed that your CustomField "C" is a Text Field.

Thank You Alejandro. It is working.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events