From e6e64192562024277f3aac36c7b40ef3a722225b Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Wed, 29 Oct 2025 21:07:51 +0530 Subject: [PATCH 1/3] Create Readme.md --- .../Catalog Client Script/Document validation/Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Client-Side Components/Catalog Client Script/Document validation/Readme.md diff --git a/Client-Side Components/Catalog Client Script/Document validation/Readme.md b/Client-Side Components/Catalog Client Script/Document validation/Readme.md new file mode 100644 index 0000000000..66975c579e --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Document validation/Readme.md @@ -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. From b506db153fbd5fe0825a130473a7997c2a46106d Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Wed, 29 Oct 2025 21:12:40 +0530 Subject: [PATCH 2/3] Create Client script.JS --- .../Document validation/Client script.JS | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Document validation/Client script.JS diff --git a/Client-Side Components/Catalog Client Script/Document validation/Client script.JS b/Client-Side Components/Catalog Client Script/Document validation/Client script.JS new file mode 100644 index 0000000000..c6e4447e7d --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Document validation/Client script.JS @@ -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; +} From 3a3843d2775a450a138b7123ee988be99a6a0c0c Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Wed, 29 Oct 2025 21:13:28 +0530 Subject: [PATCH 3/3] Create Script include.js --- .../Document validation/Script include.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Document validation/Script include.js diff --git a/Client-Side Components/Catalog Client Script/Document validation/Script include.js b/Client-Side Components/Catalog Client Script/Document validation/Script include.js new file mode 100644 index 0000000000..71c25a3771 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Document validation/Script include.js @@ -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'; + } +});