Hi,
We are using Jira 5.0.2 version and We want to hide one of issue type of project from few user groups from create issue screen. It means that this issutype should be available in creat issue screen to particular user group when they login into application, if logged in user not belong to that user group then this issue type should not present in issutypes drop down in create issue screen.
Is it possible with javascript which we can add in createissue-start.jsp file jira source and how to get user group refererence in javascript?
Community moderators have prevented the ability to post new answers.
try with following code by changing little bit as per your requirement
<script type="text/javascript"> jQuery(document).ready( function($) { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { hideIssueType(); }); hideIssueType(); function hideIssueType(){ var user=getCurrentUserName(); if(isUserInGroup(user,'Developers')){ //add code here to hide issuetype } } function getCurrentUserName() { var user; AJS.$.ajax({ url: "/rest/gadget/1.0/currentUser", type: 'get', dataType: 'json', async: false, success: function(data) { user = data.username; } }); return user; } function getGroups(user) { var groups; AJS.$.ajax({ url: "/rest/api/2/user?username="+user+"&expand=groups", type: 'get', dataType: 'json', async: false, success: function(data) { groups = data.groups.items; } }); return groups; } function isUserInGroup(user, group){ var groups = getGroups(user); for (i = 0; i < groups.length; i++){ if (groups[i].name == group){ return true; } } return false; } }); </script>
Hi Prasad,
Thanks for your response on this. I have tried with above code like adding java script in createissue-start.jsp page, but it is not triggering while creating issue(added alerts test this). Where we have to add this javascript in createissue-start.jsp file i mean on any onclike event we have to call this javascript ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
add the above script in footer.jsp or load it as webresource module in a plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Yes you can do it with javascript and rest-api , but it will be difficult for you if you do not have good knowledges of JavaScript and rest-api
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.