User id in HTML Macro in confluence

Hi,

I am using HTML macro in Confluence and want filter the data in a field on the basis of user who is logged in. 

Can somebody help me how to detect in the html macro, the current user who is logged in Confluence? will be a great help.

Thanks

Sanan

1 answer

0 vote
Stephen Deutsch Community Champion Jan 25, 2018

Hi Sanan,

In Javascript, you could use AJS.params.remoteUser to get the current logged in user's username.

Hi stephen,

thanks for your reply. I will try it out and let you know what happened.

 

Regards

sanan

Hi Stephen,

This realy works. Infact, it can work from javascript file also I have on the server.

I have one more question. AJS.params.remoteUser gives back the userid . is there any way to get the full name of user?

The data I have have is mapped to the full username . if can catch full user name in the html macro then I can just compare and match with the user name column in the datasheet.

Regards

sanan

OK. i got it. is AJS.params.currentUserFullname

Stephen Deutsch Community Champion Jan 25, 2018

Good, you could also get it as AJS.Meta.get("current-user-fullname")

That searches through the <meta> tags on the page, which also have some extra information.

Thank you, Stephen. 

will definitely try your tips out.

 

Regards

Sanan

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

385 views 21 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you