Hello! I am attempting to locate a behavior script for scriptrunner for Jira Cloud.
Use case scenario:
When an issue is set to highest or high priority, we want to require another field to be filled in that is getting missed. I'm hoping this is possible with behaviors for scriptrunner in Jira Cloud, but I have been unsuccessful in writing or locating a script that will do this.
Thanks in advance!
Hello @Jane Ellis
Are you trying to set the field to be required while the issue is being created? Or are you talking about the Priority being changed after the issue has been created?
Evaluation of other fields Required state is not evaluated when the issue is being edited since all editing is now done in Jira Cloud inline. Only the field that is being edited can be evaluated during the Edit operation to see if it is required.
Behaviours can be used to conditionally make a field Required only in the Create Issue dialog.
On creation, preferably. I knew it would be an issue during editing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you try a script similar to the example provided in the Behaviours documentation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The issue is that both of the fields we're using are standard jira fields, so I can't call them the way that script does and it's throwing errors when I try to change it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show us your changed script and tell us what error you are getting.
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.
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.
Hello @Jane Ellis
I have tried the same script and a similar script from this Youtube video.
https://www.youtube.com/watch?v=T_22rKXWNrg
In both cases I am getting this error:
"Property 'value' does not exist on type 'string | LabelsField | { accountId: string; } | ComponentsField | { accountId: string; } | IssueTypeField | { version: 1; type: "doc"; content: unknown[]; } | ... 9 more ... | { ...; }'. Property 'value' does not exist on type 'string'."
The documentation and the video are the only references I have seen that are applicable to Jira Cloud.
In absence of other references, I recommend that you reach out to Adaptavist support directly about this. Their contact information can be found in their Marketplace listing:
It would be great if you report back here what you learn, for the benefit of other members of the community.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I’m not getting any errors. That’s the thing! It’s just not doing what I want it to do. :( I know it’s because priority isn’t a custom field, but every time I’ve changed it to what I think it should be, it still doesn’t work.
If you remove the .value, it still doesn’t work. It’s super annoying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think it has to do with Priority not being a custom field.
I think my response with the video link got posted at about the same time you were posting your reply, so you probably hadn't seen it yet.
Following the video I linked above, I removed the line about checking the changed field type.
I tried using both "value" and "name" as the attributes after "getValue()" and got the same error message.
I also tried adding logger.info statements, but the Logs page for ScriptRunner shows no logs found for Behaviours.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Trudy Claspill ! Thank you so much for that youtube video!! It was a HUGE help! In piecing the two scripts together (the one from your initial comment), I was able to accomplish what I needed!!! See below (I know there is an error, but it still works!):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is GREAT!!
It is good to know that even though the code shows an error, it actually executes correctly.
If you found my responses to be helpful in solving your problem, please consider clicking the Accept Answer button. That will help others searching the community find posts with details of working solutions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have accomplished this using jira workflow conditions and validators.
If my condition checkbox called "needs ops review" is checked, then the field "ops reviewer" is required (validator).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I should clarify -- if they don't provide the required field then the workflow step won't get completed (in your case, "create issue."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Crystal Baker it looks like you're achieving this with an app, JSU. I don't have the ability to purchase that right now and already have scriptrunner installed. The conditions and validators "out of the box" don't work the same way.
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.
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.