Forums

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

When using AUI to create a form in a confluence page, the Save buttons ignore Javascript

Sondra Menthers August 19, 2020

I am using AUI to create a form with the HTML macro in a Confluence page.  When the save button is clicked, I want it to either save to a text file or save it to JSON.  I have used JavaScript for this, which works fine in my testing areas, but does nothing from the Confluence form.  Is there a workaround to save form data? 

2 answers

1 accepted

0 votes
Answer accepted
Jiri Hronik
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 27, 2020

Hi @Sondra Menthers .

Could you share the code snippet or create a https://jsfiddle.net/ that would show what you're trying to do?

Sondra Menthers August 28, 2020

I uploaded the code here

https://jsfiddle.net/sondramenthers/pt27ndhg/

 

Of course, it is returning nothing because it is supposed to get the data from the form which I wrote using the AUI class which is all in HTML.  The code for the button is

</div>

<!--Add to button to save the data.-->
<div>
<input type="button" id="bt" value="Save data to file" onclick="saveFile()"

</div>

0 votes
Alex Medved _ConfiForms_
Community Champion
August 28, 2020

Well, you certainly cannot save the form's data into a file. 

But what you can try to do is to handle form submit in a way that creates a file on-the-fly and  uses Confluence REST APIs and submits it as an attachment (basically uploading "submitted" data as an attachment on to some page)

If you want something more sophisticated then you need to create a "backend service" that handles your form submits and does what you want. You can always create a custom plugin for Confluence - https://developer.atlassian.com/server/framework/atlassian-sdk/

Sondra Menthers August 28, 2020

Creating it on the fly is fine. Ideally, I would like the attachment to be emailed or slacked but that might be too difficult.

Alex Medved _ConfiForms_
Community Champion
August 28, 2020

Well, I am pretty sure you can use slack APIs to send a message right from the browser, they do have web API

I briefly looked at the jsfiddle (not my business really and dont want to interrupt your conversation), and I suggest to take a look at what Confluence has to offer - https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html

 

easier to use with jquery they have, and toInit method is also a nice thing to do (things properly)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events