Hello Atlassian community!
I'm trying to set the value of a field depending on the selection in another field.
I use "Behavior" but none of the options found on the Internet solved my problem.
I have two fields: "CPU" and "RAM". My task: depending on the choice in cpu, automatically substitute the value in ram.
if value in :
cf_CPU = 2
cf_RAM:
(select list options)
2,
4,
8
if value in :
cf_CPU = 4
cf_RAM:
(select list options)
4,
8,
16
Hi @Alex
This appears to be a very common Behaviour question.
You can find a similar question and solution in this Community Post.
Thank you and Kind regards,
Ram
@Ram Kumar Aravindakshan _Adaptavist_
Hello! Unfortunately, this code does not work for me, perhaps because of "def list1 = getFieldById(fieldChanged)" because there are identical values in cpu and ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex
The objective of using fieldChanged is to ensure the Server-Side Behaviour will only trigger if a modification has been made to the field the Server-Side Behaviour has been configured for.
In your case it is for the CPU field.
Could you please share a screenshot of your Behaviour configuration so I can get a better idea why it is not working for you?
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.
Yes, sure!)
my screen :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ Stop!
I think I found one of the problems! I had two fields with the same name. That's why it didn't work. I named the field "RAM" and now it shows "none"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ I removed the duplicate field and now my screen looks like this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex
Could you please tell me what version of Jira and ScriptRunner you are currently using?
I'm asking this because this seems like a bug and need to check the versions you are using
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.
@Ram Kumar Aravindakshan _Adaptavist_ Understood. I looked at the version. I have 8.5.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex
Could please try and update you ScriptRunner plugin to the latest release, 8.14.0 and see if issue persists?
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.
@Ram Kumar Aravindakshan _Adaptavist_
Unfortunately, I don’t have the opportunity to update this plugin, because we have a lot of scripts and maybe they will break ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex
Upgrading ScriptRunner has nothing related to your script breaking.
If your scripts are faulty that's another issue.
Please upgrade your ScriptRunner plugin to the latest release.
Another test I suggest would be to go into safe mode and ensure only your ScriptRunner plugin is enabled and rerun the test.
If the issue cannot be reproduced then it's not caused by ScriptRunner but by some other plugin.
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.
@Ram Kumar Aravindakshan _Adaptavist_
Are you sure that the problem is in the unupdated application? And how does safe mode work in jira? Will I be able to update to the latest version and, if something happens, roll back in this mode? or how does it work? Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_
Is there any other way to fix the code to make it work?
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex
In your last comment, you asked:-
Are you sure that the problem is in the unupdated application?
Yes, I am sure it will not cause any problems in the updated release.
You also asked:-
And how does safe mode work in jira? Will I be able to update to the latest version and, if something happens, roll back in this mode? or how does it work?
Safe Mode function is to disable all add-ons that have been added to your jira instance, i.e. only the original features that come with Jira will be available. Once you do this to verify if the problem is caused by ScriptRunner or not, you must only enable the ScriptRunner plugin and re-run the test.
Also, from the screenshot you shared, your Behaviour configuration is incorrect.
As I mentioned in my previous comment, you must use the Server-Side Behavior for your requirement for the CPU field. Instead, in your environment, it appears you have used the Behaviour Initialiser instead. This will not work.
Please make the following changes:-
1. Delete the current Behaviour Initialiser configuration that you have created.
2. Select the CPU field in the Add Field List available in the Behaviour configuration.
3. Next, create a Server-Side Behaviour configuration for the CPU field.
4. Copy the sample code I provided in the Community Post.
5. Please ensure that you modify the code accordingly in your environment, as the sample code in the link provided is not 100% exact to your environment. Do not just copy and paste the code and expect it to work.
6. Please ensure you have upgraded your ScriptRunner plugin to the latest release, i.e. 8.14.0.
7. Finally, go into Safe-Mode with only ScriptRunner enabled and re-run the test.
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 @Alex
Were you able to get it to work? If you still have an issue, please let me know, and I will try to update the example according to your requirements.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.