Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Access content of a table from user macro

Hi, I would like to create an user macro which gets content from a table. The table is on a different page from the one where the user macro i placed. 

Is it possible to access content of a table on another page from an user macro?

 

My final goal is to create an user macro which lists all incoming links, but only those which are placed in a specific table on other pages. 

2 comments

Hello @Michal Michal 

have you wrapped the table in a Page Properties Macro? Doing so, allows you to create a Page Property Report. Here you can define a label, and receive results of the table in a centralized list, showing only entry types you defined.

For more information take a look at the official documentation of the page properties macro and the page properties report

Cheers,

Andrej

Thanks, I know the Page Properties Macro and this is not what I want to do. 

I want to extract content of a specific table (or part of a table) and use that content in a user macro. 

Sorry to hear that this did not help you. In case the content is within a single cell of the table, or consists of the whole table, you could also use the excerpt macro. But this seems to be far less than what you are trying to achieve.

Having the page properties macro as a base, you could create a user macro that does exactly that, but maybe someone else will have a better idea 😊 

My first thought would be that you could create a user macro with a parameter to select a page. That parameter will create a velocity variable that you could pop into some JavaScript to do a REST call to get the contents of the page. From there it would be parsing through the page storage format with JavaScript.

I would tend to use JavaScript for this in a user macro instead of velocity. It's actually not too hard to get the page content with velocity, but since velocity is really only a page templating language there aren't very good/easy ways to parse though the page storage format with it.

I too think that I should go for JavaScript. Selecting a page is not an issue. I will use the incoming links. 

Well, I try to get the content of a page but I keep getting 404 page not found error. 

function getContent()
{
jQuery.ajax({
url: "/rest/api/content/77562249",
type: 'get',
dataType: 'html',
async: false,
success: function(data) {
    var h = document.createElement("H1");  
    var t = document.createTextNode(data);
    h.appendChild(t);
    document.getElementById("div1").appendChild(h);
},
error: function (xhr, ajaxOptions, thrownError) {
    var h = document.createElement("H1");
    var t = document.createTextNode(xhr.status + " " + thrownError);
    h.appendChild(t);
    document.getElementById("div1").appendChild(h);
}
});
return;
}

 

/rest/api/content/77562249 works in a browser, but not in the user macro

/rest/api/space works both in macro and in browser

Sorry, got it working now :-)

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

Calling all Confluence Cloud Admins!  We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...

159 views 2 11
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you