How to write a Groovy Script to check if a user belongs to a group and hide a field ?

Andrian F February 1, 2017

Hi All,
I want to write a Groovy Script to check if the current user belongs to a given group or project role. And based on that I want to hide certain fields on the screen. Is this possible with a groovy script ?
If possible, what is the syntax to check the current users group and hide a given custom field in groovy ?
Also please let me know what classes to import.

Thanks for Reading
Andrian

3 answers

1 vote
Doug Swartz
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.
February 1, 2017

What plugin are you using to write your groovy scripts? If you're using the Adaptivist Scriptrunner plugin, you have behaviors available. See this page for hidden fields behaviours documentation.

Andrian F February 6, 2017

Hi @Doug Swartz

Do you know how to get rid of the below message in Behaviour Plugin. I want hide fields in the view screen. But according to the below message I can only do it in the edit screen. 

The field Description is not hideable, so it will only be hidden when the issue is editable

Any thoughts ?

0 votes
Goran Dermeta August 19, 2019

Hi folks,

 

I have the same question, but I am using JMWE add-on. Been playing with variables, but can't find how to check if current user is member of the role.

 

Thanks a bunch

Goran Dermeta August 19, 2019

These are the steps i have in PF, after create event:

The following will be processed after the transition occurs

  1. Creates the issue originally.
  2. The first applicable transition from this list will be triggered on the issue:
    • Open of workflow TEST WF

    Run this post-function only if the following condition is true:

    currentUser.isInProjectRole("Developers", issue.get("project"))

     

  3. Re-index an issue to keep indexes in sync with the database.
  4. Fire a Issue Created event that can be processed by the listeners.
0 votes
Andrian F February 6, 2017

@Doug Swartz

Thanks a bunch man. I do have this plugin.

Andrian

Suggest an answer

Log in or Sign up to answer