Hi folks,
I need to hide SLA div from issue view screen based on user role. Cause I don't want to expose internal SLA information to customers (cause we opened our JIRA URL for our customers). So, when the user belongs to the Customer role, I need to hide SLA div.
In order to achieve such result I tried to use Behavior ADD-ON. But, since JIRA Service Desk fields are not hideable, it was not possible to use such option.
After that, inspecting elements from issue view screen I identified the id of SLA div, which is:
<div id="sla-web-panel" class="module toggle-wrap">
...So I thought to use some JS as a possible solution.
The main problem is I'm not a good programmer...
So, could you please send me some JS codes to address this particular need? Thanks in advance. Best,
Michel
In fact I discovered my own need was to hide SLA div panel based on a specific group (not a role).
Due to that, I wrote the code below, put it into Summary description in the respective field configuration scheme and it worked properly.
<script type="text/javascript"> jQuery(document).ready(function() { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { hideSLAPanel(); }); hideSLAPanel(); function hideSLAPanel() { var user=getCurrentUserName() if(isUserInGroup(user,'<define your own group here>')) { AJS.$('#sla-web-panel').hide(); } else { AJS.$('#sla-web-panel').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>
Rest APIs are GREAT, specially if combined to JS.
Is it possible to do the same thing based on project role instead of group?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jesse, I think so, but you will need to check APIs library in order to localize Project Role availability. If not available, you will need to write a JS code using project role objects and collections to interact using an specific user. Please let me know whether such information will help you. Best regards, Michel Barros
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.