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 looking to build out something that would automatically update priority of issue dependent on value of numerical custom field I have created in Scriptrunner (Numerical Custom Field C). I think has to be built out via Scriptrunner Behaviour, but am not sure on how to write script as I'm very new to scriptrunner. Any help would be greatly appreciated.
For background, I have a numerical custom field I created via scriptrunner (Custom field C) which is the result of two numerical custom fields being multiplied (Numerical Custom Field A and Numerical Custom Field B)
Modified to the below, but doesn't appear to work.
Also to note, my custom field Rating does not appear on create screen, despite being in scope, being added to field configuration, and being added to field screen
For your requirement, you must create a Server-Side Behaviour for the custom number field.
Below is a working sample code for your reference:-
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleNumber = getFieldById(fieldChanged)
def sampleNumberValue = sampleNumber.value as Long
def priority = getFieldById(PRIORITY)
if (sampleNumberValue >= 10) {
priority.setFormValue(1) // highest
} else if (sampleNumberValue >= 8 && sampleNumberValue < 10) {
priority.setFormValue(2) // high
} else if (sampleNumberValue >= 6 && sampleNumberValue < 8) {
priority.setFormValue(3) // medium
} else if (sampleNumberValue >= 4 && sampleNumberValue < 6) {
priority.setFormValue(4) // low
} else if (sampleNumberValue >= 2 && sampleNumberValue < 4) {
priority.setFormValue(5) // lowest
}
Please note that the working sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Behaviour configuration:-
Below are a couple of test screenshots for your reference:-
If you observe the screenshot displayed above, you will notice as the number field is updated, the priority field is updated accordingly.
I hope this helps to answer your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please share a screenshot of your Behaviour configuration?
In your last comment, you mentioned:-
Also to note, my custom field Rating does not appear on create screen, despite being in scope, being added to field configuration, and being added to field screen
Please clarify, on which screen have you added your Rating field? Is it on a Transition screen, or is it not visible, although you have added it to your Create screen?
Kindly share the screenshots of your screen configuration so I can get a clearer picture and provide you with a better solution.
Also, please reply to this message thread.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ here is screenshot of behaviour.
And Rating custom field is on Create, Edit, and View Screen, however it's not visible on Create screen
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.