Forums

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

Hide Screen tab from current user as Reporter on Edit Screen when a custom field value is selected?

Digvijay Singh Gehlot
Contributor
July 22, 2024

Hi Community,

I have created two screen tabs (Tab A, Tab B) and running a scriptrunner behaviour where I am showing the Tab A on Status A and Tab B on Status B only when opening Issue Edit screen.

My use-case is:

In Issue Edit Screen, I want to hide Tab B from the current user as Reporter if a value in the custom field (present on Tab A) is selected under Status A.

Please guide on how I can restrict the current user as Reporter to view the Tab B in Edit Screen based on a custom field value (present on Tab A) by using either scriptrunner, JMWE app, or JIRA Automation. It would be a great help.

Thank you.

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
July 22, 2024

Hi @Digvijay Singh Gehlot

For your requirement, it would be best to use the Server-Side Behaviour for the field you intend to use to determine if the tab should be hidden or not.

Below is a sample working code for your reference:-

import com.adaptavist.hapi.jira.users.Users
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def sampleList = getFieldById(fieldChanged)
def sampleListValue = sampleList.value.toString()

showTab(1)

if (sampleListValue == 'Option1' && underlyingIssue && Users.loggedInUser == underlyingIssue.reporter ) {
hideTab(1)
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to modify it accordingly.

Below is a screenshot of the Server-Side Behaviour configuration:-

behaviour_config.png

 

In my environment, I have set the Server-Side Behaviour for a Single Select List called Sample List.

So, the value Option1 is selected from the Sample List, and if I am logged in as the issue Reporter, the 2nd Tab will be hidden. Otherwise, if any other option is selected from the Sample List, the 2nd Tab will be made visible.

Below are a couple of test screenshots for your reference:-
1. If I'm logged in as the Issue Reporter and the option selected in the Sample List is Option1, Tab 2 is hidden as shown in the screenshot below:-
test1.png
2. Else, if the option in the Sample List is not Option1, Tab 2 is made visible as shown in the screenshot below:-
test2.png
I hope this helps to solve your question. :-)

Thank you and Kind regards,
Ram
TAGS
AUG Leaders

Atlassian Community Events