Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,760
Community Members
 
Community Events
168
Community Groups

user details for macro

Hello,

trying to find what parameters are available in user macros as below.

As in I just want the users firstname to show but cannot seem to get the syntax correct.

$action.remoteUser.name   (works)
$action.remoteUser.FullName  (works)
$action.remoteUser.FirstName  (nothing)
$action.remoteUser.LastName  (nothing)

 

 is there any documentation showing this  data?

 

thanks

1 answer

1 vote

Here are some of the functions available to the Confluence User object:

https://docs.atlassian.com/atlassian-confluence/6.6.0/com/atlassian/confluence/user/ConfluenceUserImpl.html

Unfortunately, there's nothing available to pull the first name, as Confluence doesn't keep track of which part of the full name is a first name, middle name, or last name. However, you could assume that it is the first word of the full name string in most cases. Therefore you could use something like this:

#set ( $fullName = $action.remoteUser.fullName )
#for ( $word in $fullName.split(" ") )
#set ( $firstName = $word )
#break
#end
<p>$firstName</p>

thank you Stephen

Use #foreach, not #for (source: https://stackoverflow.com/questions/5683690/how-to-use-for-loop-in-velocity-template)

Since I'm using the user macro inline, I've skipped the <p> </p> bit.

This code works for me:

#set ( $fullName = $action.remoteUser.fullName )
#foreach ( $word in $fullName.split(" ") )
#set ( $firstName = $word )
#break
#end
$firstName

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events