How to set default permissions for comments

How and where can I Set default permissions for comments? I don't want (by default) that my customers can see comments which are added by my developers.

3 answers

1 accepted

Hi Pawel,

All users (also customers) are added to the jira-users group by default. If you add a comment to an issue this comment will be visible for this jira-users group by default. If you want your comment to be visible only by one group, f.e jira-developers, you can change the scope of the comment here:

The comment will only be visible for the selected group. All users refers to the default jira-users group.

Hope this answers you question?!

This small tutorial shows you how to set the default group that sees your comments:

https://developer.atlassian.com/display/JIRADEV/How+to+Set+Default+Comment+Security+Level

Hi Benji, I know it exactly :) But I need it to be automatic, because sometimes my developers forget about this option and then our customers could see comments. which they shouldn't see ;)

Hi Pawel,

Have a look at this template file:

WEB-INF/classes/templates/jira/global.vm

Around line 28 you find the templating that is used for setting the available options for comment visibility.

There I have this code (from 1 to 47 line):

## comment-edit.vm

#macro (createLevelSelect $roleLevels $groupLevels $selected)
#set($currentSelection = "$i18n.getText('security.level.viewable.by.all')")
#set($locked = false)
#if ($isRolePresent)
#foreach ($level in $roleLevels)
#if($level.id && $selected == "role:${level.id.toString()}")
#set($currentSelection = "$i18n.getText('security.level.restricted.to', ${textutils.htmlEncode($level.name)})")
#set($locked = true)
#end
#end
#end
#if ($isGroupPresent)
#foreach ($level in $groupLevels)
#if($level && $selected == "group:${level}")
#set($currentSelection = "$i18n.getText('security.level.restricted.to', ${textutils.htmlEncode($level)})")
#set($locked = true)
#end
#end
#end
<div class="security-level">
<fieldset class="hidden parameters">
<input type="hidden" title="securityLevelViewableByAll" value="$i18n.getText('security.level.viewable.by.all')">
<input type="hidden" title="securityLevelViewableRestrictedTo" value="$i18n.getText('security.level.restricted.to')">
</fieldset>
<a class="drop" href="#"><span class="icon #if($locked)icon-locked #else icon-unlocked#end"></span><span class="icon drop-menu"></span></a>
<select name="commentLevel" id="commentLevel">
<option value="">$textutils.htmlEncode($i18n.getText('comment.constants.allusers'))</option>
#if ($isRolePresent)
<optgroup label="$i18n.getText('common.words.project.roles')">
#foreach ($level in $roleLevels)
<option value="role:${level.id}" #if($level.id && $selected == "role:${level.id.toString()}")selected="selected"#end>$textutils.htmlEncode($level.name)</option>
#end
</optgroup>
#end
#if ($isGroupPresent)
<optgroup label="$i18n.getText('common.words.groups')">
#foreach ($level in $groupLevels)
<option value="group:${textutils.htmlEncode($level)}" #if($level && $selected == "group:${level}")selected="selected"#end>$textutils.htmlEncode($level)</option>
#end
</optgroup>
#end
</select>
<span class="current-level">$currentSelection</span>
</div>
#end

What I have to change?

Hi Pawel,

Here is how to do it:

1) Open the file WEB-INF/classes/templates/jira/global.vm in your favorite text editor

2) Locate the following code:

#macro (createLevelSelect $roleLevels $groupLevels $selected)
    #set($currentSelection = "$i18n.getText('security.level.viewable.by.all')")
    #set($locked = false)
    #if ($isRolePresent)
        #foreach ($level in $roleLevels)
            #if($level.id &amp;&amp; $selected == "role:${level.id.toString()}")
                #set($currentSelection = "$i18n.getText('security.level.restricted.to', ${textutils.htmlEncode($level.name)})")
                #set($locked = true)
            #end
        #end
    #end

and replace it by:

#macro (createLevelSelect $roleLevels $groupLevels $selected)
    #set($selected = "role:10002")
    #set($currentSelection = "$i18n.getText('security.level.viewable.by.all')")
    #set($locked = false)
    #if ($isRolePresent)
        #foreach ($level in $roleLevels)
            #if($level.id &amp;&amp; $selected == "role:${level.id.toString()}")
                #set($currentSelection = "$i18n.getText('security.level.restricted.to', ${textutils.htmlEncode($level.name)})")
                #set($locked = true)
            #end
        #end
    #end

The line #set($selected = "role:10002") sets the default role. You have to find the role or group that suites your needs and use that id.

It is possible that you also have to restart your JIRA instance (not sure :))

Hope this helps?!

I have to change the default role, but... IT'S WORKING! :) THANKS A LOT!

You are welcome, Pawel! :)

No, because my original file looks like this:

#disable_html_escaping()
$!{auiparams.put("controlHeaderClass", "aui-field-componentspicker $!fieldLayoutItem.rendererType")}
#customControlHeader ($action $field.id $i18n.getText($field.nameKey) $fieldLayoutItem.required $displayParameters $auiparams)
#if ($components && !$components.empty)
#if ($!isFrotherControl)<div class="ajs-multi-select-placeholder textarea long-field"></div>#end
#if (!$fieldLayoutItem.required)
#set ( $componentHeaderSize = 1)
#end
<select class="select #if ($!isFrotherControl)hidden#end" id="$field.id" multiple="multiple" name="$field.id"
size="#minSelectSize($components $componentHeaderSize 5)"
data-remove-null-options="true" data-submit-input-val="true" data-input-text="$textutils.htmlEncode($!frotherInputText)">
#if (!$fieldLayoutItem.required)
<option#if ($currentComponents && $unknownComponentId && $currentComponents.contains($unknownComponentId)) selected="selected"#end value="-1">
$i18n.getText('common.words.unknown')
</option>
#end
#foreach ($component in $components)
<option#if ($currentComponents && $component && $currentComponents.contains($component.getLong('id'))) selected="selected"#end title="$textutils.htmlEncode($component.getString("name")) #if($component.getString("description")) - $textutils.htmlEncode($component.getString("description"))#end" value="$!component.getLong('id')">
$textutils.htmlEncode($component.getString('name'))
</option>
#end
</select>
#if ($!isFrotherControl)<div class="description">${i18n.getText('generic.picker.static.desc')}</div>#end
#displayFieldWarning($displayParameters, $i18n.getText('bulk.edit.warning.component'))
#else
<span class="field-value">$i18n.getText('common.words.none')</span>
#end
#customControlFooter ($action $field.id $fieldLayoutItem.getFieldDescription() $displayParameters $auiparams)
$!{auiparams.clear()}

I suggest that you selected the wrong file. It seems that you selected the components-edit.vm but you must edit the comment-edit.vm! My JIRA version is 6.2.4 and the comment-edit.vm looks like described in the above link.

Please follow this instructions. It works!

I use 6.2.3 version. How can I should get the upgrade?

That's good and all is fine! Please lookup for the right file.

I know where is the problem. I don't have this file there. Is it normal?

No, that's not normal. You should have this file otherwise it is not possible to add comments. Can you post a list of all files in this folder please?

I found this file: /../atlassian/jira/atlassian-jira/WEB-INF/classes/templates/jira/issue/field - it isn't proper?

Yes, the folder is right. Now, you need this file:

..\classes\templates\jira\issue\field\comment-edit.vm

assignee-columnview.vm
assignee-edit-no-context.vm
assignee-edit.vm
assignee-view.vm
attachment-edit.vm
components-bulkmove.vm
components-columnview.vm
components-edit.vm
components-view.vm
creator-columnview.vm
creator-view.vm
date-columnview.vm
date-excelview.vm
description-columnview.vm
description-edit.vm
duedate-columnview.vm
duedate-edit.vm
duedate-view.vm
duration-columnview.vm
environment-columnview.vm
environment-edit.vm
issuelinks-columnview.vm
issuelinks-edit.vm
issuelinks-view.vm
issue-operations.vm
issuetype-columnview.vm
issuetype-edit-not-allowed.vm
issuetype-edit.vm
issuetype-view.vm
key-columnview.vm
labels-columnview.vm
labels-edit.vm
labels-view.vm
priority-columnview.vm
priority-edit.vm
priority-view.vm
progress-bar.vm
project-columnview.vm
project-edit.vm
reporter-columnview.vm
reporter-edit-frother.vm
reporter-edit.vm
reporter-view.vm
resolution-columnview.vm
resolutiondate-columnview.vm
resolution-edit.vm
resolution-view.vm
securitylevel-columnview.vm
securitylevel-edit.vm
securitylevel-subtask.vm
securitylevel-view.vm
status-columnview.vm
subtask-columnview.vm
summary-columnview.vm
summary-edit.vm
textfield-view.vm
thumbnail-columnview.vm
timetracking-bulkmove.vm
timetracking-edit.vm
timetracking-view.vm
userpickerfilter-config.soy
versions-bulkmove.vm
versions-columnview.vm
versions-edit.vm
versions-view.vm
votes-columnview.vm
watches-columnview.vm
worklog-edit.vm
workratio-columnview.vm

Something is wrong with your JIRA instance. Please repair your instance. There are two files missing: comment-edit.vm and comment-view.vm

In Jira 6.x, comment-edit.vm has been renamed and moved.

You will now find it at:

/../atlassian-jira/WEB-INF/classes/templates/plugin/comment/system-comment-field-edit.vm

All users refers to the default jira-users group.

i dont think this is true. Setting a comment scope of "all users" allows users in a group other than jira-users to see the comment. However, selecting the jira-users group does hide the comment from groups other than jira-users. I witnessed this in 6.2.7

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Mar 09, 2018 in Jira Service Desk

E.L. Fridge's take on education, Jira Service Desk, and creative Jira use cases

...word of mouth, so by 2016, we were working with several other entities on campus to implement Jira Service Desk . The Atlassian motto of “for every team” has really come true for us in this case. We...

965 views 2 14
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you