Hi,
how can I make a field read-only based on another custom field value?
For example, I have 2 custom fields: "reviewed" and "effort".
I want the following:
when "reviewed" is empty, "effort" field is editable
when "reviewed" is non-empty, the "effort" field is a read-only field.
I believe it can be done by using behaviors but not sure how :(
thanks!
Hi @Liat Yanco
Please check https://library.adaptavist.com/ There you can find a lot of examples and scripts ready to use.
I think this script will be helpfull :) https://library.adaptavist.com/entity/set-behaviour-read-only
Regards
Seba
Thanks for this @Sebastian Krzewiński !
but I want to base the read-only option with a condition - that another custom field is empty or non-empty:
when "reviewed" is empty, "effort" field is editable
when "reviewed" is non-empty, the "effort" field is a read-only field
in the example you attached, it is to make the field read-only with no condition.
any other idea? :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can check other scripts and figure out how to do this :)
I didn't test it but please check this code:
import com.atlassian.jira.issue.IssueFieldConstants
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def effortField = getFieldByName("Effort_Name")
def reviewedField = getFieldByName("Reviewed Name")
if (effortField.getValue()) {
reviewedField.setReadOnly(true)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried the above and i'm getting the below error:
"Parsing XML failed: Content is not allowed in prolog."
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.
here in the 'behavior':
I copied your suggestion and got the error: "Parsing XML failed: Content is not allowed in prolog."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Pleade write steps how you get view from the screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm working on Jira server V6.4.
Jira administration --> add-ons --> Behaviours --> created a new Behaviours --> click Edit in the line of the new behavior that was just created
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Based on https://scriptrunner.adaptavist.com/4.3.19/jira/behaviours-overview.html try to add code above in inline script section.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OK, so you were right.
it is working!!
thank you so much for your help and support :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems like this doesn't work well at scriptrunner ver 6.0.2-p5
JIRA ver 8.7.1
Kindly,
Gilad
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.