Hello Community ! I just want to ask if it is possible to hide unrelated fields on Edit Screen based on the Requests Screen
Scenario is:
*Requestor creates a ticket, and he/she needs to fill up 3 fields (Field1, Field2 , Field3)
*Upon creation, Agent wants to edit the issue , so he/she will click on Edit , on Agent Side
However, all fields are visible on Agent Side
Can Behavior on Scriptrunner hide unrelated fields , and let fields that is related to request only show on Edit Screen? If possible, any sample code will be much appreciated. Thank you!
Community moderators have prevented the ability to post new answers.
Hello @Alvin
Yes you can do it with BEHAVIOURS. You can hide field based on the project role or group or user name.
https://scriptrunner.adaptavist.com/4.3.1/jira/behaviours-overview.html
Regards
Hi @Mohamed Benziane, how about based on the request itself?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it is possible you will need to add server-side script.
When you said based on the request you mean the issuetype or the value of the three filled fields ?
i'm not sure if its helps but here a sample code:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_10339")
def cField2= customFieldManager.getCustomFieldObject("customfield_10340")
def cFieldValue = issue.getCustomFieldValue(cField)
def cFieldValue2 = issue.getCustomFieldValue(cField2)
your condition
You will need to use variable.setHidden(true)
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mohamed Benziane, the issuetype and the fields that are only visible on the request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I need to make it generalize as possible since we have many request types with different custom fields
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 an expert and you will need to work on this but to help you who can begin with this:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_10339")
def cField2= customFieldManager.getCustomFieldObject("customfield_10340")
def cFieldValue = issue.getCustomFieldValue(cField)
def cFieldValue2 = issue.getCustomFieldValue(cField2)
If (issue.issueTypeObject.name == "yourissuetype"||cFieldValue="your value"){
cFieldValue2.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 @Mohamed Benziane , Thank you for your help. I will try to make it generalize, like if custom fields is not equal to the custom field on request type, then don't display it on .setHidden(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.
Its okay @Mohamed Benziane, you helped me a lot. Very much appreciated. Thank you!
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.