Limit issue types based on user group? Jira ScriptRunner

Rodrigo Gomez February 3, 2025

Hello, I have been trying to limit the issue type based on the user group to specific project with no success via Behaviours on Jira ScriptRunner.

Example User belongs to the group JIRAtests should only be available to create issuetypes A and B, while users that do not belong to JIRAtest should be able to create issue types A, B and C

 

I was trying to achieve this via Scriptrunner behaviors but no success at all.


 

const issueTypeField = getFieldById("issuetype")

const user = await makeRequest("/rest/api/2/myself");
const { accountId } = user.body;
const userGroups= await makeRequest("/rest/api/2/user/groups?accountId=" + accountId);
const groupNames = userGroups.body.map(({ name }) => name);

// Select the group that the specific issue types will be shown for.
const group = "JIRAtest";

if (groupNames.includes(group)) {
    issueTypeField.setOptionsVisibility(["10040", "10011"], true)
}
Is there another way or is there something wrong on the code?  thanksScreenshot 2025-02-03 155556.png

3 answers

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
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 4, 2025

Hi Rodrigo,

I can confirm that in Jira Cloud, the Behaviours feature does not support Jira Service Management, which means there is no way to restrict issue types on creation in Service Management at this time.

You can see the products and projects types behaviours supports in the documentation page located here.

Also, the example script here shows how to restrict issue types to users in certain groups in supported project types.

I hope this information helps.

Regards,

Kristian

2 votes
Trudy Claspill
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 3, 2025

Hello @Rodrigo Gomez 

I think the syntax of your line here is incorrect:

 

const userGroups= await makeRequest("/rest/api/2/user/groups?accountId=" + accountId);
Looking at the example code in this video from Adaptavist:
... the code should be
const userGroups= await makeRequest("/rest/api/2/user/groups?accountId=${accountId}");
Rodrigo Gomez February 6, 2025

I have modified but seems this is not compatible with Jira Service Management

 

thanks for the help

1 vote
Joseph Chung Yin
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 3, 2025

@Rodrigo Gomez -

In addition to what @Trudy Claspill pointed out on the syntax error, please kept in mind that in JSM what users sees are the Request Types to create his/her issues for your JSM project.

Request Type is based on the IssueType allowed in your project.  So are you asking to restrict request types access based on group association?  If, take a look at this reference link out of the box for JSM to restrict request type access for issue creation (without using Behavior setup) -

https://support.atlassian.com/jira-service-management-cloud/docs/add-or-remove-restrictions-on-request-types/

Hope this helps.

Best, Joseph Chung Yin

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events