Hi Community, is it possible to show/hide custom fields on edit issue screen based on value of System Field?
Scenario is when an agent wants to edit Priority Field , if he/she chooses Priority 1, related custom fields will be shown for Priority 1 in Edit Issue Screen, if Priority 2, related custom fields for Priority 2 will be shown in Edit Issue Screen .
Is it achievable on Behavior? or in Script Listener? or Validator? Thanks
Below is my code on behavior server-side script Priority(system field) , it does not follow the condition
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
def customField = getFieldById("customfield_10802")
def priority = getFieldByName("Priority")
if(priority.getValue() as String == ("Priority 1") || ("Priority 2")) {
log.debug(priority)
customField.setFormValue(null)
customField.setRequired(true)
} else {
if(priority.getValue() as String == ("Priority 3") || ("Priority 4"))
log.debug(priority)
customField.setHidden(false)
customField.setRequired(false)
}
Thank you!
Hi,
It is not working for priority field. Please help me:
I am using the below code:
if(field1.getValue() == "P1" || field1.getValue() == "P2")
{
field2.setHidden(false)
field2.setRequired(true)
}
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.
Hi Alvin
Here is sample code using Behavior,
def priority = getFieldByName("Priority")
def customfield1 = getFieldByName("Name of custom field1")
def customfield2 = getFieldByName("Name of custom field2")
if (priority.getValue() == 1)
{
customfield1.setHidden(false)
customfield2.setHidden(true)
}
if (priority.getValue() == 2)
{
customfield1.setHidden(true)
customfield2.setHidden(false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Deng, thank you for the quick turn-around. will try this then. will give you feedback. thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It does not do the condition on Edit Issue Screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you mind to share your code and how did you set the behavior? Did you map the behavior to your project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did used your code and mapped the behavior to project, also, I add Priority and added your code to server-side script
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried it from my side, added "" like priority.getValue() == "1", and it works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Deng, I have my custom value on Priority, it does not work, it does not follow the condition in else statement. is this working on edit screen?
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.