You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.