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,
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.