Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide Unrelated fields on Edit Screen

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 17, 2018

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

Screenshot from 2018-09-18 11_34_53.png

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!

1 answer

0 votes
Mohamed Benziane
Community Champion
September 18, 2018

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

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018

Hi @Mohamed Benziane, how about based on the request itself?

Mohamed Benziane
Community Champion
September 18, 2018

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

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018

Hi @Mohamed Benziane, the issuetype and the fields that are only visible on the request.

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018

I need to make it generalize as possible since we have many request types with different custom fields

Mohamed Benziane
Community Champion
September 18, 2018

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))}
Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018 edited

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)

Mohamed Benziane
Community Champion
September 18, 2018

Hi @Alvin

Glad i helped you, sorry i can help you more i'm very very new in groovy.

 

Regards

Alvin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2018

Its okay @Mohamed Benziane, you helped me a lot. Very much appreciated. Thank you!

Mohamed Benziane
Community Champion
September 18, 2018

You're welcome @Alvin the community is here for that!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events