Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
  • Community
  • Products
  • Confluence
  • Questions
  • How can I add some custom JavaScript or a little snippet that will use the Confluence API to grab current user's info to a Confluence page?

How can I add some custom JavaScript or a little snippet that will use the Confluence API to grab current user's info to a Confluence page?

MacGregor Thompson July 18, 2016

I'm a developer working on a project and have never used Confluence before. Is there a way to add some custom javascript or a little snippet to a confluence page to let me grab the current user's info and then pass that along?


Details:
1) Confluence web page has a button.
2) When a user clicks that button, I want to use the confluence api to grab the user's info, open a new window to the url with the user's info attached as the query string.

 

Basically, I just want to know if there's a way add a snippet using the confluence api. I have the api method I need, but am having trouble figuring out how it can be added to the page. One of our customer's uses Confluence for their company and is requesting this feature.

1 answer

1 vote
Sarah Heimeier July 20, 2016

Hi MacGregor, 
If I understand correctly what you are wanting to do, to add JavaScript into a Confluence page you need to insert the HTML macro. To do this go to the Confluence editor, click Insert > Other Macros, and search for HTML macro. Then insert it into the page. Inside the HTML macro, you can then add the JavaScript code.


I hope this helps

MacGregor Thompson July 21, 2016

Well the issue is that the steps to turn on the html macro don't work.

  1. Go to  > Add-ons.

  2. Select System from the drop down and search for the Confluence HTML Macros add-on.
  3. Expand the add-on and enable the html (html-xhtml) module.

The only thing listed that has 'html' in it is 'Atlassian XHTML'.  

 

If you do what you say, the only html macros listed are as follows:

1) HTML Comment

2) HTML Image

3) HTML Table

4) List Item (li)

5) Ordered List (ol)

6) Table Body (tbody)

7) Table Cell (td)

8) Table Head (th)

9) Table Head (thead)

10) Table Rod (tr)

11) Unordered List (ul)

 

None of these help me out.  So neither the steps to turn on the HTML macro work, nor do the steps for adding it (I would presume since it's not enabled in the first place).

Sarah Heimeier July 21, 2016

Hi MacGregor, 
Are you using Cloud or Server?

If you are using Cloud, you won't be able to use the HTML macro. Although, you can use the Atlassian Connect (https://developer.atlassian.com/static/connect/docs/latest/index.html). This allows you to build add-ons to customise your Atlassian products. 

If you are using Server, then you may need your admin to enable the html macro. To do this, please refer to this document: https://confluence.atlassian.com/conf54/confluence-administrator-s-guide/managing-add-ons-and-macros/enabling-and-configuring-macros/enabling-html-macros

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events