Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use a Confluence current user name as a JQL variable in an on-page JIRA macro?

Kevin Baldwin October 7, 2019

I am using a JIRA macro on an on-prem Confluence 6.14.2 page. 

In the macro, as part of the JIRA issue filter, I want to use the currently logged-on Confluence user as a variable in the JIRA assignee field.  Then, I'll restrict editing of the page so that users cannot see any issues that are assigned to others.  Users can only see their own issues, at least in Confluence.  (!Important)

What is the easiest way to get the current Confluence user name to appear in the filter field of the JIRA macro?  (The Confluence platform admin has locked down creation of User Macros, so my solution will have to probably use only on-page javascript, or similar.)

Here is my xhtml:

<p>
<ac:structured-macro ac:macro-id="39265a4e-f7e7-4c75-b8c2-c956cde9922c" ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">ServerName</ac:parameter>
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="maximumIssues">20</ac:parameter>
<ac:parameter ac:name="jqlQuery">project = PROJECT AND status != Done AND assignee = [current Confluence user] </ac:parameter>
<ac:parameter ac:name="serverId">3094394f-4ff6-3c13-8625-7c1a63b63bf9</ac:parameter>
</ac:structured-macro>
</p>

Thanks, --K

1 answer

0 votes
RianS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 8, 2019

You should be able to use the currentUser() function in the JQL query:

So you would use this for the JQL:

project = "PROJECT" AND status != "Done" AND assignee = currentUser()

 
This should search based on the current logged in user from the context of Confluence.

Kevin Baldwin October 8, 2019

That is the exact variable that I was trying, and for some reason it stopped working this week.  I had it working last week, but this week instead of using the currentUser() variable string, the JIRA macro resolved the variable string to my logon id string -- essentially hard-typing it into place for all users of the page.

Now today, inexplicably, it is indeed working again.  What is going on with the currentUser() variable that sometimes works and sometimes does not?!!

Kevin Baldwin October 9, 2019

Still no word on why the currentUser() variable sometimes works and sometimes doesn't in the Edit mode of a Confluence page.  Thanks, --K

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events