Hi,
We are using JIRA 5.0.2 version and We want show "create sub task" option to only particular group, is it possible?
Community moderators have prevented the ability to post new answers.
add this javascript on footer.jsp or load it as webresource module in a plugin
<script type="text/javascript"> jQuery(document).ready(function($) { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { hideTab(); }); hideTab(); function hideTab(){ var user=getCurrentUserName(); //change group as per your requirement if(isUserInGroup(user,'Developers')){ $("#create-subtask").hide(); //if you want to hide "Convert to Sub-Task" operation then use this $("#issue-to-subtask").hide(); }else{ $("#create-subtask").show(); $("#issue-to-subtask").show(); } } 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 help. I have tried with above script like adding to footer.jsp, but it is not working. what i have observed that rest call to get current user that is getCurrentUserName() method returing "undefined" value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
which version of jira you are using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
then i don't think the problem with the getCurrentUserName() method, are you passing correct group name as parameter?
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.
Yes Prasad, i am passing correct group only. i have debuged with firbug and found this error in console.
<html><head><title>Apache Tomcat/5.5.29 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /rest/gadget/1.0/currentUser</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/rest/gadget/1.0/currentUser</u></p><p><b>description</b> <u>The requested resource (/rest/gadget/1.0/currentUser) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.29</h3></body></html>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you try this on your browser
<your instance url>/rest/gadget/1.0/currentUser
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad,
I have already tried with my instance context path and found that rest call is working fine, but "create-subtask" option is still enabled for that group.
What i have observed that page is already loaded before executing javascript that is why it is not hiding create-subtask option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you try with my updated answer!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have tried and user name and group details coming properly but "create-subtask" option is not hidden.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in jira 5.2.5 the id for this operation is "create-subtask" so same you can check on your jira instance with firebug!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad,
Thanks for your help, now it is working fine.
I have modified below javascript little bit and then it is working fine.
if(isUserInGroup(user,'Developer')){ AJS.$("#create-subtask").hide(); //if you want to hide "Convert to Sub-Task" operation then use this AJS.$("#issue-to-subtask").hide(); }else{ AJS.$("#create-subtask").show(); AJS.$("#issue-to-subtask").show(); }
Thanks a lot for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to hear it worked!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad,
Thanks for your help, now it is working fine. The problem with below code earlier
if(isUserInGroup(user,'Developers')){ $("#create-subtask").hide(); //if you want to hide "Convert to Sub-Task" operation then use this $("#issue-to-subtask").hide(); }else{ $("#create-subtask").show(); $("#issue-to-subtask").show(); }
Now i have modified above code to added AJS reference then it is working fine.
if(isUserInGroup(user,'Nagpur-IT')){ AJS.$("#create-subtask").hide(); //if you want to hide "Convert to Sub-Task" operation then use this AJS.$("#issue-to-subtask").hide(); }else{ AJS.$("#create-subtask").show(); AJS.$("#issue-to-subtask").show(); }
Thanks a lot for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ramesh Udari1 Hi Can you help me to solve this issue. I was in the same boat but was not figure it out how to do this one. Could you please explain me in details how you did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
as of now who have create issue permission can create subtasks also, to implement create sub tasks permission improvement request has submitted, check this
https://jira.atlassian.com/browse/JRA-8521
workaround: you can do this by using javascript
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad,
Thanks for your response on this. Can you please explain bit more on workaround. I mean by using javascript how can i achieve this ?
Thanks
Tom
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.