Forums

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

Update page after executing macro

Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

I have built a user macro that displays as a button that, when selected automatically de-selects any checkboxes on the page.

The macro works successfully, but doesn't actually update the page so, when you refresh the page, the checkboxes are still selected.

How would I need to update the macro so that it saves the changes to the page?

2 answers

1 accepted

0 votes
Answer accepted
Brita Moorus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

Hi, @Matt Parks! 👋

Can you give more background info on how you've built the user macro?

Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

Here's the code of the macro. Not much to it. I would assume that I would put something right before the </script>, but I don't know what and haven't been able to figure it out.

## @noparams
<script>
function myFunction() {
    Array.from(document.getElementsByClassName('checked')).forEach((el) => el.classList.remove('checked'));
};
</script>

<button type="button" id="myBtn" onclick="myFunction()">Try it</button>

Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

I wouldn't have thought that I needed to save the changes, since I don't have to if I'm just manually de-selecting a checkbox, but the checkboxes don't stay de-selected after refreshing the page or navigating away and then back.

Brita Moorus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

So your macro's JavaScript currently only changes the visual state on the page (removing the CSS class 'checked'), but it doesn't actually update or save the page content in Confluence. This is why after a refresh, the checkboxes revert back.

Confluence stores page content on the server, and your JS runs only on the client side. To save the changes, you need to update the page content via Confluence’s API or editing framework - something that isn't achievable by client-side JS alone in a user macro.

Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2025

Thank you for the explanation. I'll let my macro developer know that this is what they'll need to do.

Like • Brita Moorus likes this
0 votes
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

It's likely that the front-end code listens to an event that happens when the checkbox is clicked on. Maybe you could try changing

el.classList.remove('checked')

 to

el.click()

in your script and see if that makes any difference?

Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2025

Unfortunately, the only difference it makes is that the checkboxes are no longer un-checked. I appreciate the assistance, though!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.17
TAGS
AUG Leaders

Atlassian Community Events