Forums

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

Restrict Multi-Select Field Options to Specific User Groups using Scriptrunner for JIRA Cloud

Digvijay Singh
Contributor
March 16, 2025

Hi Community,

I want to restrict the visibility of select list (multiple choice) field options to specific user groups and on a Create transition using Scriptrunner for Jira Cloud.

My use-case is: On Create View, 

  • If currentUser is from Admin group, then show all options ("Bitbucket", "Confluence", "Jira") in multi-select field Platform drop-down.
  • If currentUser is from User group, then show options ("Confluence" & "Jira") but hide ("Bitbucket") in multi-select field drop-down.
  • If currentUser is from Developer group, then show options ("Bitbucket", "Confluence") but hide ("Jira") in multi-select field drop down.

I am able to code my request in groovy in Jira Data Center as below:

import com.atlassian.jira.component.ComponentAccessor 
def groupManager = ComponentAccessor.getGroupManager()
def group1 = ComponentAccessor.groupManager.getGroup("User Group")
def group2 = ComponentAccessor.groupManager.getGroup("Developer Group")
def group3 = ComponentAccessor.groupManager.getGroup("Admin Group")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def platformQus = getFieldByName("Platform")
def platformQusCF = customFieldManager.getCustomFieldObjectsByName("Platform")[0]
def config = platformQusCF.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)
if((ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find
{(it.name == "User Group") || it.name == "Admin Group" && it.name != "Developer Group"}))
{def newOptions = options.findAll
{it.value in ["Jira", "Confluence"]}
platformQus.setFieldOptions(newOptions)
}
else if((ComponentAccessor.getGroupManager().getGroupsForUser(currentUser)?.find
{(it.name == "Developer Group") || it.name == "Admin Group" && it.name != "User Group"}))
{def newOptions = options.findAll
{it.value in ["Bitbucket", "Confluence"]}    
platformQus.setFieldOptions(newOptions)
}
else
{ def newOptions = options.findAll
{it.value in ["Confluence", "Bitbucket", "Jira"]}
platformQus.setFieldOptions(newOptions)
}

But I want to code the same logic in Jira Cloud using Scriptrunner behavior.

Please guide on how we can achieve the above.

Thanks

1 answer

Suggest an answer

Log in or Sign up to answer
2 votes
Digvijay Singh
Contributor
March 16, 2025

Hi @Kristian Walker _Adaptavist_ 

May you please guide me with Javascript/ typescript code for the above request using Scriptrunner for Jira Cloud?

It would be a great help if you could share any javascript code wrt multi-select field options, or any Adaptavist examples for my reference.

Looking forward to hearing from you soon.

Thanks

Kristian Walker _Adaptavist_
Community Champion
March 17, 2025

Hi Digvijay,

I can confirm the best place to see example scripts for ScriptRunner Jira Cloud is either in the documentation pages or in our script examples website.

As for your use case, we do not have an example of restricting issue-type options based on a user group here, and you will be able to modify this to restrict select field options based on user groups.

If you need further assistance modifying the script, please raise a support request, and our support team will assist you.

Regards,

Kristian

Digvijay Singh
Contributor
March 18, 2025

Hi @Kristian Walker _Adaptavist_ 

Thank you for your message and sharing the necessary link. 

If I understood you correctly, we can't hide the custom field - specific options from a particular user group using scriptrunner in jira cloud? 

Because I tried configuring the below code and user who's a part of User and/or Admin groups but Not a part Developer group, is still able to see complete list of options under custom field Business Areas such as "Jira", "Confluence", "Bitbucket" on the Create View screen? - It should only show Jira, Confluence only to user. 

IMG_20250318_134632.jpg

It didn't give any errors in behavior but the changes are not reflecting on Create screen. I also checked the permission scheme and user groups are added to Issue create permission. 

Please let me know if I am missing out something. 

Thanks

Kristian Walker _Adaptavist_
Community Champion
March 18, 2025

Hi Digvijay,

Can you please raise a support ticket so our support team can help look at the script? They will help you create the script you require to solve your requirements.

Regards,

Kristian

Like Digvijay Singh likes this
TAGS
AUG Leaders

Atlassian Community Events