We have 1 ScriptRunner scripted field. We want to hide 2 JIRA custom fields on Edit Screen based on the logic:
if scripted = value a
else
We've tried Behaviour function from ScriptRunner but no luck. Please advise.
Scripted fields are calculated fields, so can't be edited, so will never appear on a screen.
Therefore you can't get the value from behaviours, but you can get it from the java API for the issue.
Eg:
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("Some Scripted Field") def cfValue = underlyingIssue?.getCustomFieldValue(cf) if (cfValue == "foo") { getFieldById("summary").setRequired(true) // etc } else { // ... }
Great. It works. Thanks a lot.
Here is my code
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("MJE, IC, CAPEX") def cfValue = underlyingIssue?.getCustomFieldValue(cf) if (cfValue == "Capex") { getFieldByName("Target Go Live Date").setRequired(true) getFieldByName("Project id").setRequired(true) getFieldByName("Target Go Live Date").setHidden(false) getFieldByName("Project id").setRequired(false) } else { getFieldByName("Target Go Live Date").setHidden(true) getFieldByName("Project id").setHidden(true) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I'd recommend taking a look at our article in the documentation that shows how to make a field mandatory or hidden based on the value of another select list field. It should help you get a long way towards configuring Behaviours to do this.
regards, Mark.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
I've read the document on ScriptRunner carefully but it seems that it cannot work with scripted field. It only can be done by JIRA custom field (select list ...). Is it correct?
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.