Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function onSubmit() {
var ga = new GlideAjax('DocumentValidationHelper');
ga.addParam('sysparm_name', 'validateAttachments');
ga.addParam('sysparm_item_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
if (response !== 'valid') {
alert('Document validation failed: ' + response);
return false;
}
});
return true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This project enhances a Service Catalog item by allowing users to upload supporting documents (e.g., ID proof, approval letters) and validating them before the request is submitted. It ensures compliance, completeness, and proper documentation for sensitive or regulated requests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var DocumentValidationHelper = Class.create();
DocumentValidationHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, {
validateAttachments: function() {
var itemId = this.getParameter('sysparm_item_id');
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', 'sc_req_item');
attachmentGR.addQuery('table_sys_id', itemId);
attachmentGR.query();

while (attachmentGR.next()) {
var fileName = attachmentGR.file_name.toLowerCase();
if (!fileName.endsWith('.pdf') && !fileName.endsWith('.docx')) {
return 'Only PDF or DOCX files are allowed.';
}
if (attachmentGR.size_bytes > 5 * 1024 * 1024) {
return 'File size exceeds 5MB limit.';
}
}

return 'valid';
}
});
Loading