Example scripts
To homepage
Jira

Limit issue types based on user role
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira
Language |
typescript
// Note: You should run this script by selecting "On load" in the check box above.
const context = await getContext();
const projectId = context.extension.project.id;
const projectRoles = await makeRequest(`/rest/api/3/project/${projectId}/roledetails?currentMember=true`);
const projectRoleNames = projectRoles.body.map(role => role.name);
const issueTypeField = getFieldById("issuetype");
const allowedIssueTypeIds = ['10133', '10134']; // IDs for Story and Task
if (projectRoleNames.includes('Developers')) {
issueTypeField.setOptionsVisibility(allowedIssueTypeIds, true);
if (!allowedIssueTypeIds.includes(issueTypeField.getValue()?.id)) {
issueTypeField.setValue("10133"); // Default to Story if the current value is not allowed
}
}
Having an issue with this script?
Report it here