Custom Exports with JavaScript
- 15 Mar 2022
- 1 Minute to read
- Print
- DarkLight
Custom Exports with JavaScript
- Updated on 15 Mar 2022
- 1 Minute to read
- Print
- DarkLight
Article Summary
Share feedback
Thanks for sharing your feedback!
Intro
ancoreShare Extension provides a JavaScript API to access the generated report file.
In this way you can export your reports for example to a custom URL, upload them on an FTP server, or anything else you can think of using JavaScript.
To enable custom export, perform the following steps:
Access export option
Configure custom exportIn the On After Export field, click fx to use the expression editor and enter your JavaScript code that will be executed on after the event of generating the report file there. You will already find several examples and comments in this section to support you. |
Sample Code
Here's a sample code that you can use to send the report to a custom URL.
In this sample, we have sent the exported file to Atlassian using a REST API.
/* Debug your code: Open browser developer console (F12): */
//debugger
//Upload file via REST Service
const url = ""; // URL to REST Service
const user = "";
const password = "";
let actionData=new FormData();
actionData.append("file", file, filename);
actionData.append("comment", subject);
$.ajax({
type: "POST",
url: url,
data: actionData,
processData: false,
headers: {
"Authorization": "Basic " + btoa(user + ":" + password),
"X-Atlassian-Token": "no-check",
"cache-control": "no-cache"
},
contentType: false,
cache: false,
success: function (data, status, response) {
webix.message({type: "success", text: filename + "
Custom Upload succeeded."});
},
error: function(response){
webix.message({expire:-1, type: "error", text: filename + " Custom Upload failed.
" + (response.responseText || response.statusText)});
}
});
Info
Don't forget to update the variables as per your requirement.
Next Steps:
Was this article helpful?