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

Kiran Chauhan February 18, 2021

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

1 vote
Kiran Chauhan August 25, 2021

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>"}

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 18, 2021

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?

Vruti Thakkar April 15, 2021

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.

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2021

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?

Vruti Thakkar April 15, 2021

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. 

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 16, 2021

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.

Vruti Thakkar April 20, 2021

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events