user details for macro

Darren Johnston March 19, 2018

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

2 answers

1 vote
Stephen Deutsch
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.
March 20, 2018

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>
Darren Johnston March 20, 2018

thank you Stephen

Lasse Kaiser September 13, 2022

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
0 votes
Roman Joss
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.
April 14, 2023

Hello @Stephen Deutsch 

Ware are on the way to update Confluence from 7.13.x to 7.19.x and I have found out that the the following code does not work in 7.19.x

$action.remoteUser.FullName

Not work mean, that exact this string is shown in the page instead of the fullname of the user.
Do you have an idea if there was a change in the code?
I have several macros with the $action-function which do not work anymore.

Thanks for your assistance.
Roman

Roman Joss
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.
April 14, 2023

Oh, after a several more searches I've found the following bug.

CONFSERVER-82741

This is my workaround!
Most of my macroes work again and now I have to enhance the property with my needs.

Sorry for disturbing.
Regards, Roman

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events