Hi Team,
I am new to Scriptrunner Fragments and I want to hide the Create button present on Top Navigation bar on Dashboard only.
I am using Hide system and plugin UI elements under Scriptrunner Fragments, and in Hide What: I am able to find the location of this web item: com.atlassian.jira.jira-header-plugin:create-issue
When passing the Condition as:
(jiraHelper.project?.key != "<issue-key>")
I am able to see that Create button on Top Navigation Bar is hidden, but it is also hidden on all pages under that specific project.
My requirement is, I just want to hide the Create button on a particular Dashboard Page ID i.e. https://<jira-instance>.atlassian.net/secure/Dashboard.jspa?selectPageID=XXXXX
Please guide me on how to write the correct condition as per the above requirement in Scriptrunner Fragment.
Thanks.
Fragments have a binding variable "jiraHelper", which you'll see when you hit 'Help' in the fragment editor.
Which goes to: https://docs.atlassian.com/software/jira/docs/api/9.12.8/com/atlassian/jira/plugin/webfragment/model/JiraHelper.html
From the javadoc, you can debug the available/known values inside the condition, like this:
log.warn("== debug start ==")
log.warn("request uri: " + jiraHelper.getRequest().getRequestURI())
def params = jiraHelper.getRequest().getParameterMap()
params.entrySet().forEach((entry) -> {
log.warn("debug entry.. " + entry.getKey() + ":" + entry.getValue())
})
log.warn("== debug end ==")
Which results in log containing this:
== debug start == request uri: /secure/Dashboard.jspa debug entry.. selectPageId:[23100] == debug end =
Therefore you might conclude that the following would work in your case:
String requestUri = jiraHelper.getRequest().getRequestURI()
String dashboardId = jiraHelper.getRequest().getParameter("selectPageId")
if (requestUri.endsWith("Dashboard.jspa") && "20310".equals(dashboardId)) {
return false // because fragments, false should mean.. hide? I think
}
return true // either not a dashboard, or no id in params, so display the button
That said, your use case is rather.. peculiar? And also, if the dashboard is your "default" dashboard, it won't include the ID in url. I.e. opening just dashboard with no ID will show you the first one off the list, which might be the one you are trying to detect, but you couldn't in this case.
I really do not like fragments and they will run on basically every page visit so you can expect a tiny tiny performance hit when each page request has to go through this filter. (Which I mean, it's 1 or few milliseconds at best, but still).
Thank you so much for your message.
I am able to configure the same at my end, and it is working as per my expectations.
Create button is only hidden on a particular Dashboard - selectPageID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have one more requirement,
How can I hide the Top Navigation Bar - Create button, and below that Project Name, Issue Key and Summary Title on Edit Issue link: https://<jira-instance>.com/secure/EditIssue!default.jspa?id=XXXXX page?
While doing inspect on EditIssue!default.jspa page - I could see that Project Name (has id="project-name-val"), Issue Key (as id="key-val"), and Summary title (as id="summary-val")
But I am unable to locate these web items/links under Hide what section.
Is there a way I can hide these hyperlinks and the Create button (at Top Navigation Bar) on the Edit Issue link, having a dynamic url with {issue.id}?
Or atleast, we can disable the hyperlinks on Project Name, Issue Key, and Summary title on EditIssue!default.jspa?id={issue.id}?
Please suggest with a possible solution.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Issue screens are not for fragments, that's like taking a hammer to spread the butter.
It's what Behaviours are for:
# https://docs.adaptavist.com/sr4js/latest/features/behaviours
So as a quick hint you create a behaviour, map it to the project, and then
getFieldById("field_id").setHidden(true)
Where the id should be "summary", "something else", and "something else", I have no idea what you mean by project name and issue key, neither of which is really a field.
Again, I sincerely think this is a wrong approach and what you are trying to do is making Jira simply more difficult to work with, and it completely changes the way it behaves and works that will only make things confusing. I can't think of any good reason to be hiding the elementary data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Community,
How can I use Dashboard's selectPageID in Jira automation?
My use-case is:
In Jira automation, I have selected:
Trigger as When: Issue created
Action as Then: Edit issue
Here, I want to pass a dynamic url as a hyperlink in a custom field i.e.
[Click here to Dashboard|https://<jira-instance>.com/secure/Dashboard.jspa?selectPageID=XXXX]
What will be the correct syntax to call dynamic value of "selectPageID" in the above automation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.