Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to hide issue type to few user groups in jira5

Ramesh Udari1 September 11, 2013

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?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2013

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>

Ramesh Udari1 September 11, 2013

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 ?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2013

add the above script in footer.jsp or load it as webresource module in a plugin

0 votes
Nadir MEZIANI
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2013

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

TAGS
AUG Leaders

Atlassian Community Events