Hello,
I have a custom field "Risk Value" which is a Number field.
I have created another custom field "Risk Level" which is a Text field.
I want to populate values in "Risk Level" whenever a value is entered in "Risk Value". (Event: Issue Created)
Scenario:
1. If Risk Value takes: 0-5,
Risk Level is equals to Low,
Else if Risk Value takes : 6-10,
Risk Level is equals to Moderate
Else if Risk Level is equals to High
I tried to create an event based and added some groovyy expression, but I'm not getting any result when I'm creating a new ticket.
What I have done so far:
Can anyone please advise what is wrong with the expressions or whether this is achievable?
Thanks.
Hello @Joseph Chung Yin & @David Fischer ,
Thank you very much for your answers.
I have removed the "" from the expression, the logs is showing success but the field Risk Level is still not displaying in the ticket created.
I'm sharing with you my workings:
Do you have an idea why the field and its value is not being displayed?
Note that the field Risk Level is a non editable field
Hi @Krishtee
what do you mean by "the field Risk Level is a non editable field"? What is the custom field type, and how did you make it non-editable? Normally, to make it non-editable, you remove it from the "Edit" screen, is that what you did?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @David Fischer ,
Yes I have removed the field from the edit screen because the value will be dependent on the value of field “Risk Value”. Users should not have the possibility to modify the value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And what is the custom field type of that field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A regular, single line text field? Not a read-only text field? In that case it should definitely work. You can click on the green checkmark to see the execution logs and make sure the event-based action ran on the issue you think it did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it is a regular text field which I have just removed from the edit screen.
Yes, the log is showing successfully completed and is referring to the correct ticket and issue type.
But despite being executed successfully, the field is not present in the ticket.
That's what I'm not able to figure out why the field Risk Level and its associated value are not being displayed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And did you make sure it's on the "View" screen?
Also, one thing you could do to test further is add default value, adding this as the last line:
else return "VALUE DID NOT MATCH"
and check if you then see the field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes the field is available on the view screen.
As you mentioned, I have added the last line and effectively it is outputting the result "Value did not match". The Risk Value is 7 and it should have displayed Medium for the Risk Level
Can you advise why it is not performing the if and else if section?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Fischer When I'm updating the values of "Risk Value" for an existing issue of issue type "Impediment", the rule is working correctly.
It's only when creating new issue of issue type "Impediment", the rule is executing the else section (That is it is returning: "VALUE DID NOT MATCH")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have managed to make it work.
I have changed the event of the trigger to Generic Event instead of Issue created.
Thanks a lot for your help :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Krishtee I understand you try to accomplish this using a post function. I see two obstacles here
I might suggest using Automation to set Risk level based on Risk value. The automation example below should update Risk level, and also constantly maintain it correctly.
If you don't have Automation installed I would recommend you get it because it really boost Jira to another level. Automation for Jira is free. It is still downloadable for server.
TimK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Tim Kopperud ,
Thanks for your help.
I tried the automation with the rule
When: Rule is triggered on
If: Risk Value
between
0 and 5
Then: Edit issue fields
Risk Level
This rule was returning the correct value but only for the triggger Issue Updated. It was not returning the value for the trigger Issue Created
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Krishtee, That was strange.
I tested the rule using the Issue created trigger. The rule now looks like this:
The newly created issue was updated as shown below:
So, it works as expected.
Can you attach an image of your rule? And an image of the the entry in the Audit log? It will be helpfull for further investigation of why it doesn't update the Risk Level on "your side".
TimK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Krishtee
since the Risk Value field is a Number field, the constants you use in the Groovy expression should be numbers, not strings (e.g. 0 instead of "0")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One other suggestion -
Try to use the following code when testing for Number custom field
issue.get("customfield_12710") == 0 instead of issue.get("customfield_12710") == "0"
Your current code typically is checking for non-Number field value.
Hope this helps.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Technology Applications Team
Viasat Inc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide the entire post function screen (i.e. Target issue section etc)... Secondly, have you turn on debugging against the add-on and see what is captured (i.e. errors) in the system's logs? Also have you included your 2nd custom field in your issue screen for your issue type setup?
You can also reach out to JMWE vendor for technical support. Based on my experience with the vendor, they are really good on assisting users with technical questions too.
Please advise.
Best, Joseph Chung Yin
Jira/JSM Functional Lead, Global Technology Applications Team
Viasat Inc.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.