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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

903 views 23 12
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