Want to add "Upload" Ui action in custom table for the list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2025 02:39 AM
I have created a custom table in which i want a "Upload" ui action so give me proper script, my table name is "branch master upload"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2025 11:24 PM
Hello @MahendraG233225,
Create Upload UI action from System Definition > UI Action
Use this script to upload.
function onClick() {
// Example: Redirect to a custom file upload page for this record
var recordSysId = g_form.getUniqueValue();
var tableName = g_form.getTableName();
// Redirect to a custom UI Page (you must create it)
var url = '/your_custom_upload_page.do?sys_id=' + recordSysId;
window.open(url, '_blank'); // or use '_self' to open in same tab
}
If my response marked please mark it as correct,
Best regards,
Rohan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2025 11:30 PM
Not working when i'm clicking on the "Upload" Ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 12:20 AM
Code For UI Action :-
function onClickUpload() {
var ga = new GlideAjax('BranchMasterUploadUtils');
ga.addParam('sysparm_name', 'uploadFile');
ga.addParam('sysparm_record_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
if (result == 'success') {
gsftSubmit(null, g_form.getFormElement(), 'refresh'); // optional
alert("Upload successful.");
} else {
alert("Upload failed: " + result);
}
});
}
Code for Script include :-
var BranchMasterUploadUtils = Class.create();
BranchMasterUploadUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
uploadFile: function() {
var recordId = this.getParameter('sysparm_record_id');
if (!recordId) return "No Record ID";
// Example logic – you can customize to read attachments, update fields, etc.
var gr = new GlideRecord('branch_master_upload');
if (gr.get(recordId)) {
// Sample business logic
gr.u_status = 'Uploaded'; // Assume a status field exists
gr.update();
return "success";
}
return "Record not found";
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 01:15 AM
Not working