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? thanks