-
Suggestion
-
Resolution: Unresolved
-
None
-
None
-
None
-
10
-
4
-
We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.
NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? See the corresponding suggestion.
We would like to be able to include a single field from a JIRA issue in a Confluence page.
A very similar question was asked on Atlassian Answers: https://answers.atlassian.com/questions/97825/viewing-single-fields-of-an-issue-in-confluence
However, we need to be able to do this without resorting to Rest and JSON. Apparently it used to be an option in the JIRA Issues macro, but the functionality was removed. The enhancement could either be for it to be restored, or for a separate macro to be created.
Thank you.
- relates to
-
CONFCLOUD-35826 Enhancement: macro to display single JIRA field in Confluence page
- Gathering Interest
-
CONFSERVER-35403 Custom Select columns to display for Jira Issue macro JIM single issue
- Gathering Interest
-
CONFSERVER-56556 Display Jira issue fields (default/customs) in a Single Jira Issue Macro in Confluence
- Gathering Interest
[CONFSERVER-35826] Enhancement: macro to display single JIRA field in Confluence page
Hey, You can try using an add-on like Jcreate that allows you to create a Jira Issue from inside confluence while adding many customisable fields and the option to Hide / Show all Jira Issue macros on the page.
See: https://marketplace.atlassian.com/apps/1224226/jcreate?hosting=server&tab=overview
Hi,
I can't see the screenshots - sorry.
For the security it's really simple, because we use the default Jira Issue macro inside this user macro:
<ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="columns">$paramColumns</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">$paramFilter</ac:parameter> </ac:structured-macro>
What we do is to let the user choose the column and the JQL in the params.
- In $paramColumns we insert the column the user wants.
- In $paramFilter we insert the JQL.
So there is no security risk in my opinion.
You can compare it with the source of a default macro:
<ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="columns">type,key,summary,assignee,priority,status,due</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">(resolution = Unresolved OR resolution != Unresolved)</ac:parameter> </ac:structured-macro>
Surrounding there is a <div> to add the CSS (Styling) to hide the lines and borders.
$("div.$filterClass div.jira-table .refresh-issues-bottom").remove(); $("div.$filterClass th.jira-macro-table-underline-pdfexport").remove(); $("div.$filterClass .jira-issues table.aui tbody tr").css("border-bottom","none"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("border-bottom","none");
And this CSS is set via JavaScript, which could be the problem for your admin. You don't need it, but without it there are lines and borders. Besides, this is the shaky part because of the timing.
Kind Regards,
Fabian
Also, are there any security risks in this code please ?
Because, our Admin team has not accepted to implement this code because they feel there are security risks in the code. What kind of security risks can we expect out of this code please ?
Thanks Fabian,
But I tried your solution with 2500, 3500 and even 6000 milliseconds, but the new line does not go.
Confluence page in Edit Mode:
Confluence page in saved mode :
Hi,
maybe this is also a timing problem - mentioned in my comment on 31/Jul/2019 https://jira.atlassian.com/browse/CONFSERVER-35826?focusedCommentId=2014169&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-2014169
Kind Regards,
Fabian
Hello fabian83 ,
Thanks for pointing me to the right line in the code. By using .css("border-bottom","none"); it will remove the line at the bottom. However, there are new lines at the top and at the bottom of the rendered text. How do we remove this please.
te:
Thanks for the ScriptRunner solution, however, unfortunately we are not using Scriptrunner in our environment and hence it is not the solution at the moment for us. The script which Fabian has provided is perfect and caters our requirements. The only problem is with the newlines coming at the beginning and the ending of the text and hence it is pushing the text to the next line. If this is fixed, the code will be a perfect one with no errors.
Hi,
my collegue Fabian and I developed a ScriptRunner Macro that allows it the read field-data from Jira.
Feel free to contact us. We provide the code free of charge, but have not yet published it yet, as we are still improving it.
Regards,
Thomas
Hi there,
in my version of the user macro I added one line below this one:
$("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0");
The added line should look like this:
$("div.$filterClass .jira-issues table.aui tbody tr td").css("border-bottom","none");
With this the border on the bottom of the cell should be hidden.
In the meanwhile we found out, that there is a more elegant way to get Jira Fields with a ScriptRunner Custom script macro (https://scriptrunner.adaptavist.com/5.0.2/confluence/macros/CustomMacros.html).
Beste Regards,
Fabian
Yep Dorian. Also when I was reading the comments thread of this Suggestion Issue, I saw a comment from lisa.estrella1 on 31/Jul/2019 7:00 PM. Even she had this problem an year ago.
c1e895ad40d9 fabian83 , could one of you please help us with how to eliminate this line which is coming up under the field value when we embed the field value in the confluence page.
I didn't see that line until we recently upgraded confluence, now I see it too unfortunately.
Hello c1e895ad40d9
Your code is perfect. Only problem is when we embed the date fields inside the confluence page, it will insert a line below the date. How do we get rid of the extra lines that are coming up
Try something like this Dorian:
## Macro title: Jira Filter Field Picker ## Macro has a body: N ## ## Developed by: Fabian Hußl ## Date created: 05/12/2018 ## Native Date added by tbond ## @param Filter:title=Jira Filter|type=string|required=true|desc=Search by any key, by URL, Jira link, JQL, plain text or filter ## @param Columns:title=Column(s)|type=string|required=true|desc=Jira fields separated by commas. #set ( $filterClass = "jflp-date") <div class="$filterClass"> <ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="columns">$paramColumns</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">$paramFilter</ac:parameter> </ac:structured-macro> <div> <script type="text/javascript"> AJS.toInit(function ($){ function uuidv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }; var guid = uuidv4(); setTimeout(function () { $("div.$filterClass").attr("id", guid); $("div.$filterClass div.jira-table .refresh-issues-bottom").remove(); $("div.$filterClass th.jira-macro-table-underline-pdfexport").remove(); $("div.$filterClass .jira-issues table.aui tbody tr").css("border-bottom","none"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0"); const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var rawDateString = $("#" + guid).text(); rawDateString = rawDateString.replace("//", " "); rawDateString = rawDateString.replace(/(\r\n|\n|\r)/gm, " "); rawDateString = rawDateString.trim().substring(0,12); var theDate = new Date(rawDateString); var month = theDate.getMonth() + 1; var day = theDate.getDate(); var year = theDate.getYear() + 1900; $("#" + guid).html('<time datetime="' + year + '-' + month + '-' + day + '" class="date-upcoming">' + day + ' ' + monthNames[month-1] + ' ' + year + '</time>'); }, 1500); }); </script>
Hi all
I am using this macro to display dates from Jira issues. These dates are displayed in this format:
Apr 03, 2020
Is it possible to get them to display in the same format as the confluence date picker, i.e. the nicely rendered image like this:
https://i.imgur.com/kOzjfo8.jpg
Edit: it appears this display format is referred to in the confluence documentation as a "date lozenge"
Hi,
I figured out my question above from Aug 2nd. We have multiple Jira servers connected to Confluence so I had to add the following lines:
## @param Server:title=Server|type=string|required=true|desc=Enter the Jira Server Name. Your choices are: Jira01, Jira02, Jira03 <ac:parameter ac:name="server">$paramServer</ac:parameter>
So the full user macro template looks like this:
## Macro title: Jira Filter Field Picker ## Macro has a body: N ## ## Developed by: Fabian Hußl ## Date created: 05/12/2018 ## Installed by: Lisa Estrella ## @param Filter:title=Jira Filter|type=string|required=true|desc=Search by any key, by URL, Jira link, JQL, plain text or filter ## @param Server:title=Server|type=string|required=true|desc=Enter the Jira Server Name. Your choices are: Jira01, Jira02, Jira03 ## @param Columns:title=Column(s)|type=string|required=true|desc=Jira fields separated by commas. #set ( $filterClass = "jflp") <div class="$filterClass"> <ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="server">$paramServer</ac:parameter> <ac:parameter ac:name="columns">$paramColumns</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">$paramFilter</ac:parameter> </ac:structured-macro> <div> <script type="text/javascript"> AJS.toInit(function ($){ setTimeout(function () { $("div.$filterClass div.jira-table .refresh-issues-bottom").remove(); $("div.$filterClass th.jira-macro-table-underline-pdfexport").remove(); $("div.$filterClass .jira-issues table.aui tbody tr").css("border-bottom","none"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0"); }, 4000); }); </script>
Hi! I have another question about the User Macro. We have multiple Jira instances in our organization. When we look for a ticket that sits on the primary Jira server it returns a value. However, when we use a ticket that is sitting on another Jira server that isn't designated as a primary within Confluence, the value is not returned. Is this because we have multiple Jira servers available? Is there a way we can designate what Jira server the macro should be looking at?
Thanks for explaining in more detail Fabian. I had to increase the timing to 3500 for it to work. It still retains a line at the bottom of the value, but at least I'm making progress. So thanks for that
Example:
Hi Lisa,
you just need to create a new user macro with the code I mentioned.
As I mentioned to Katherine the <script> part in the user macro does the job for you - no headers for the Jira fields.
But it's a little bit sketchy because of the timing, when the script part runs:
<script type="text/javascript"> AJS.toInit(function ($){ setTimeout(function () { $("div.$filterClass div.jira-table .refresh-issues-bottom").remove(); $("div.$filterClass th.jira-macro-table-underline-pdfexport").remove(); $("div.$filterClass .jira-issues table.aui tbody tr").css("border-bottom","none"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0"); }, 1000); }); </script>
where 1000 means the delay in milliseconds from the page loading to the actual running of the script part, which should hide the headlines.
Please increase the value (maybe 1500, 2000 or even 2500) and have a look on the page where you use the macro. The headlines should disappear.
Radek also had troubles with the timing and went another way.
Regards,
Fabian
Hi Fabian,
As Katie stated, I only want to return the value, not the headers. I see you commented that within the <script> we can remove headers, but I am not familiar with coding or with JS so I don't know what to add or removed in order to achieve this. Are you able to help with providing sample code on how to do this? I would greatly appreciate it!
Thanks,
Lisa
Thanks for the workaround. Is it possible to remove the table frame when using the user macro?
Currently it shows the jira field with a frame above and below the value.
Hi Katherine,
the part in the <script> should remove the headers. But it's not ideal, because it's a timing challenge - see setTimeout. Maybe you have to increase the value - in the script it's one second.
Radek instead removed that JS part as he didn't like how it's loading and sometimes the 1s timeout was not enough.
Regards
Fabian
The user macro above still populates the header containing the name of the field in Jira. I need to be able to just populate the value of the field without any additional data from Jira.
fabian83, this is great workaround, thanks for it!
I've removed that JS part as I didn't like how it's loading and sometimes the 1s timeout was not enough. I've placed the following CSS into Confluence Stylesheet configuration instead. It suppress all loading and extra spaces.
The only drawback is that is not able to render custom User picker fields with full names (only loginnames). Related to JRASERVER-31023 and it seems we may see this implemented soon.
.jflp .jira-table .refresh-issues-bottom, .jflp th.jira-macro-table-underline-pdfexport { visibility: hidden; padding: 0; line-height: 0px; } .jflp .refresh-module-id { height: 0px; } .jflp .jim-sortable-dark-layout { visibility: hidden; } .jflp + p, .jflp p { margin-top: 0px !important; } .jflp .jira-issues table.aui tbody tr { border-bottom: none; } .jflp .jira-issues table.aui tbody tr td { padding: 0; }
Hi,
for this use case we use a user macro that uses the Jira Macro.
## Macro title: Jira Filter Field Picker ## Macro has a body: N ## ## Developed by: Fabian Hußl ## Date created: 05/12/2018 ## Installed by: ## @param Filter:title=Jira Filter|type=string|required=true|desc=Search by any key, by URL, Jira link, JQL, plain text or filter ## @param Columns:title=Column(s)|type=string|required=true|desc=Jira fields separated by commas. #set ( $filterClass = "jflp") <div class="$filterClass"> <ac:structured-macro ac:name="jira" ac:schema-version="1"> <ac:parameter ac:name="columns">$paramColumns</ac:parameter> <ac:parameter ac:name="maximumIssues">20</ac:parameter> <ac:parameter ac:name="jqlQuery">$paramFilter</ac:parameter> </ac:structured-macro> <div> <script type="text/javascript"> AJS.toInit(function ($){ setTimeout(function () { $("div.$filterClass div.jira-table .refresh-issues-bottom").remove(); $("div.$filterClass th.jira-macro-table-underline-pdfexport").remove(); $("div.$filterClass .jira-issues table.aui tbody tr").css("border-bottom","none"); $("div.$filterClass .jira-issues table.aui tbody tr td").css("padding","0"); }, 1000); }); </script>
Best regards Fabian
Hi, you can show just 1 custom field in Confluence:
Heading 1 | Heading 2 |
---|---|
You simply use the Jira macro, with 'key=abc-123' and under 'Display options' you choose Display as 'Table' . Next you remove all the 'Columns to display' and add the custom field you want to display. | ![]() |
This will display the field name and its value. | ![]() |
However, I'd like to have the option to hide the Field Name. This can be very useful in Page properties.
For example, if you want to show the Assignee of an issue as a Page Property, you can add this Jira macro with a single issue only showing 1 field and choose to hide the Field Name.
Currently you see this:
But that is redundant. So I'd like the option to hide the Field Name. Should I raise a separate feature request for this?
+1 In my firm, where use of custom fields is restricted in JIRA, it would be good to be able to use Confluence table to supplement the Jira with additional data (mainly for admin reporting of project financials)
Hi, for bringing JIRA issue description into a confluence requirement doc. Please!
+1. This seems like it would be desperately needed for anyone trying to implement KCS using Jira as their ticketing system and Confluence as their KB.
Even if we could customize the output of a single issue, that'd be helpful. Right now, it only displays the summary.
For example:
(<Type> <IssueNum> <Status> - <FieldDesc>: <FieldValue>)
+1
Any update on this issue? Will this be implemented in On Demand?
+1
wonder why this feature was removed (at least according to https://answers.atlassian.com/questions/97825/viewing-single-fields-of-an-issue-in-confluence)
Any Updates to this request?
We have many request for this feature in our company. We are on On Demand and would like this added or restored too.
I have the macro working, with the addition needed to remove the extra line It works fine, but there is that few seconds when it appears before it goes away, and all the timing issues around that as noted.
I've been trying to use @Radek.Janata css to remove the lines, but there is still a top line that is appearing.
In the macro code, the part that removes the header is
$("div.$filterClass th.jira-macro-table-underline-pdfexport").remove();
Which seems to be the line that removes the header, including the border
In the css code there is
Which removes the header, but still leaves the line.
I'm not a css expert. I've tried adding border: none and border-bottom: none to the block, but the line is still there.
Any ideas how to get rid of it?