Forums

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

User macro showing current user spacekey

frithjof falck
Contributor
February 1, 2022

Hello,

I'm trying to create a user macro showing the home space key of the current user in plain text. Any ideas?

2 answers

2 accepted

1 vote
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
February 1, 2022

Hi @frithjof falck ,

please create a user macro, with name and categories at your convenience, with :

  • Macro Body Processing : No macro body
  • Template :
  • ## Macro title: My Macro
    ## Macro has a body: Y or N
    ## Body processing: Selected body processing option
    ## Output: Selected output option
    ##
    ## Developed by: My Name
    ## Date created: dd/mm/yyyy
    ## Installed by: My Name

    ## This is an example macro
    ## @noparams

    #if($spaceManager.getPersonalSpace($action.remoteUser))
    $spaceManager.getPersonalSpace($action.remoteUser).getKey()
    #else
    No Personal Space
    #end

 

Key of the current user will appear if the current user has a Personal Space. Hope this helps, Fabio

Fabio Racobaldo _Herzum_
Community Champion
February 1, 2022

@frithjof falck if you need a link to that space please change Macro Body processing and add <a> in my previous code.

Ciao,

Fabio

frithjof falck
Contributor
February 1, 2022

Thanks!

Any chance of getting the home space key of the user instead of the personal space key? If that makes any sense. 

Fabio Racobaldo _Herzum_
Community Champion
February 1, 2022

Hi @frithjof falck ,

what you mean the home space key for the current user? User can have a personal space or he could be the creator of many spaces?

WHat link do you need?

Fabio

frithjof falck
Contributor
February 2, 2022

The current users space key where the homepage as set under profile settings is located.

Fabio Racobaldo _Herzum_
Community Champion
February 2, 2022

I don't find any API that is able to retrieve this setting.

frithjof falck
Contributor
February 2, 2022

Ok! Thanks for the help anyway!

0 votes
Answer accepted
Pramodh M
Community Champion
February 1, 2022

Hi @frithjof falck 

Please follow the Guide here to create the User Macro

Macro Name: spacekey
Macro Title: Space Key
Description: Adds the current space key as text
Category: Confluence Content
Macro Body Processing: No macro body
Output Format: HTML
Template: $space.getKey()

Let me know if this works

Thanks,
Pramodh

frithjof falck
Contributor
February 1, 2022

Any possibilities for the output to be the current users spacekey? I'going to add it in a <a> tag so that the user will be directeded back to its home space

Pramodh M
Community Champion
February 8, 2022

You need to use the macro for this scenario!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events