Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Create Attachment UI action button for RITM to attach onto the associated Approver request

Peter Williams
Kilo Sage

Good afternoon everyone,

 

i am trying to create a UI action button for when users need to add new attachments to their RITM request it will then attach the attachment onto the approver request for the sysapproval_approver 

i got this UI page but i can't seem to get the code to work

<j:jelly xmlns:j="jelly:core" xmlns:g="glide" xmlns:ui="jelly:ui">
<head>
<title>Upload Attachments</title>
<script type="text/javascript">
function uploadFile() {
var fileInput = document.getElementById('file_input');
var file = fileInput.files[0];
if (!file) {
alert('Please select a file to upload.');
return;
}

var ritmSysId = '${sys_id}'; // sys_id passed from UI Action

var formData = new FormData();
formData.append('file', file);
formData.append('ritm_sys_id', ritmSysId);

var xhr = new XMLHttpRequest();
xhr.open('POST', '/api/your_namespace/upload_ritm_attachment', true); // Adjust to your API path
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
alert('File successfully uploaded and attached!');
if (window.opener) {
window.opener.location.reload(); // Refresh parent page if opened from dialog
}
window.close(); // Close the dialog
} else {
alert('Failed to upload file. Error: ' + xhr.responseText);
}
}
};
xhr.send(formData);
}
</script>
</head>

<body>
<h3>Upload Attachment to Request</h3>
<p>Record sys_id: ${sys_id}</p>

<form id="attachment_form" onsubmit="uploadFile(); return false;">
<label for="file_input">Choose file:</label>
<input type="file" id="file_input" name="file" />
<br/><br/>
<button type="submit">Upload File</button>
</form>
</body>
</j:jelly>

anyhelp will be appricated

0 REPLIES 0