Hi everyone,
I'm looking for a way to hide the 'Export' button when viewing issues in a specific project on Jira Server.
I am using Jira server 9.4.14 version with data-center license.
According to Atlassian's documentation, it's possible to hide the 'Export' button using a script in the 'Announcement Banner' or by leveraging 'Fragments,' but this applies to all projects in Jira.
My goal is to restrict the visibility of the 'Export' button only for a specific project or user group.
Has anyone achieved this, or does anyone have suggestions on how to implement it? I’d really appreciate any help.
Thank you!
1- You can add JavaScript in Jira’s Announcement Banner that dynamically hides the 'Export' button based on the project you're viewing.
<script>
// Function to hide the Export button based on project key
function hideExportButton() {
// Define the project key(s) where you want to hide the button
const restrictedProjects = ['PROJ1', 'PROJ2']; // Replace with your project keys
// Get the current project key from the page
const projectKey = JIRA && JIRA.Projects && JIRA.Projects.getCurrentProjectKey();
// Check if the current project is in the restricted list
if (restrictedProjects.includes(projectKey)) {
// Hide the Export button (found in issue navigator toolbar)
const exportButton = document.querySelector('#bulkedit_all');
if (exportButton) {
exportButton.style.display = 'none';
}
}
}
// Execute the function after the page loads
document.addEventListener('DOMContentLoaded', hideExportButton);
</script>
2- ScriptRunner allows you to control fragments based on conditions. You can write a condition script that checks the project key and hides the Export button accordingly.
Example Groovy script to hide the Export button for a specific project:
import com.atlassian.jira.component.ComponentAccessor
def project = ComponentAccessor.getProjectManager().getProjectObj(issue.getProjectId())
def projectKey = project?.getKey()
// Define the project key where you want to hide the Export button
def restrictedProjects = ['PROJ1', 'PROJ2'] // Replace with your project keys
return !restrictedProjects.contains(projectKey)
JavaScript in Announcement Banner is a quick solution but only hides the button on the frontend. If user have direct url then he can do it.
ScriptRunner or other plugins can offer more control and enforce conditions at a deeper level, including user group or project-specific rules.
While either approach here should work (given some tweaks, AJS can also be used to figure out group membership), I would ask that you reconsider - any such approach is not fireproof, a user can export anything they want as much as they want, be it with a button, without it, or by other means (you might as well create a very simple shell script to fetch the issue and parse it into a csv/word, or whatever else).
The only thing such scripts achieve is ambiguity, why a piece of thing doesn't show here but it shows there, who's to know what all places to check, who's good enough to inspect the html and figure out something is hiding it, from where.
Then you have users actually wasting time trying to figure a workaround to it (which is really completely simple, but non-technical folks can bend their afternoons on it).
Unless Jira can offer this natively and enforce better and more comprehensive means of blocking certain actions, then this is folly, users will still be able to do whatever they want at the end of the day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Manoj Gangwar for your response and thanks @Radek Dostál for weighing and explaining the things
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.