Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do i get Permission Scheme name associated to Jira project using groovy script(script runner)? P

I want to let the Jira user know when the project is Temporary Restricted, on the issue screen, using custom field configuration. or do let me know if any other way is available.

 

Thanks in advance...

2 answers

Groovy Script to get things done:

 

//scheme = 11400 Temporary Restricted
//scheme = 10200 (Permanent) Restricted

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def permissionSchemeManager = ComponentAccessor.getPermissionSchemeManager()
def targetProjectKey = issue.getProjectObject().getKey()
def project = projectManager.getProjectObjByKey(targetProjectKey)

def scheme = permissionSchemeManager.getSchemeIdFor(project)
if((scheme == 11400) || (scheme == 10200)){
"THE PROJECT IS <b style='color:red;'>RESTRICTED</b>"
} else {return "THE PROJECT IS <b style='color:blue;'>LIVE</b>"}

Hi @Kiran Chauhan , welcome on the community. You will have to user REST API endpoint: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-permission-schemes/#api-rest-api-3-project-projectkeyorid-permissionscheme-get

But when the project is restricted, user can't access it. Where you want to display this information?

Hi @Martin Bayer _MoroSystems_ s_r_o__  I would like to do the same as kiran but would like to show the project Status (RESTRICTED OR LIVE) on Issue screen.

Hi @Vruti Thakkar when user does not have Browse Project permission, he will only see error message when he access URL to this project

Selection_214.png

What exactly would you like to change?

Hi @Martin Bayer _MoroSystems_ s_r_o__   user have browse project permission, I wanted to add extra custom field(Scripted Field) which reflects the project permission Scheme Name on screen, and for that I might need to write groovy script  which reflects permission scheme name, but I'm new to Groovy. 

Hi @Vruti Thakkar you can use the mentioned REST API endpoint for getting information about associated permission scheme. 

For implementation of scripted field you can use this documentation (https://scriptrunner-docs.connect.adaptavist.com/jiracloud/scripted-fields.html). There are also examples of code here:

https://scriptrunner-docs.connect.adaptavist.com/jiracloud/scripted-fields.html#_currency_conversion_number_field

 

Try to implement something and get back here for help with individual issues, please.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

658 views 16 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you