Creating Issues via direct HTML links: How do I find out current logged in user?

Riad KACED February 22, 2019

I have created some documentation on Confluence for my colleagues to use. I would like to allow them create a Jira issue from my page as described in Creating Issues via direct HTML links. Here is a sample of my HTML code:

<a href="https://seg-jira.csg.apple.com/secure/CreateIssueDetails!init.jspa?pid=10000&issuetype=4&summary=''&reporter=Riad Kaced">[File a Jira Task]</a>

Reporter being a mandatory field, I would like to set it to the current logged-in user. It is hard-coded to myself in the example above, however I want to improve my code to use the current logged-in user instead. A similar topic was discussed @ How do I find out current logged in user? The answer was: 

ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

Pasting the above verbatim into my HTML code won't work, hence my question: How to find the current logged in user with a syntax I can incorporate in my HTML code?

Cheers

2 answers

3 votes
roman smatana February 23, 2019

Hi,

If you are on Confluence and using the same user base as on JIRA, you can derive the current user in Confluence User Macro with

#set($reporter= $paramReporter)
#if (!$reporter)
#set ($reporter=$action.remoteUser.name)
#end

and complete whole HTML link.... like....

<a href="$paramJiraurl/secure/CreateIssueDetails!init.jspa?pid=$paramProjectid&issuetype=$paramIssuetype&reporter=$reporter&assignee=$assignee&summary=$paramSummary&description=$paramDescription&$paramAppendtext">$paramLinktext</a>

Check User Macros in Confluence for more.

this worked for us, I hope this help to you as well.

0 votes
Payne
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.
February 22, 2019

Not specifying the reporter should cause the field to default to the currently logged-in user, just as is the case when you click the Create button, but there is a bug that causes that not to happen - https://jira.atlassian.com/browse/JRASERVER-25308 A workaround mentions using a Behaviour, which you may consider doing if you have ScriptRunner installed.

Martin Hollerweger November 11, 2020

Issue is still open.

Suggest an answer

Log in or Sign up to answer