From b0b98f274c24c39fb1449ac944fcff3177cddb60 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 13:09:14 +0530 Subject: [PATCH 1/9] Create Readme.md test --- .../Readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md new file mode 100644 index 0000000000..d95f3ad14d --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md @@ -0,0 +1 @@ +content From 25c01a6890949ae3b1eaf5f8354aeda3762ad7ff Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 13:09:52 +0530 Subject: [PATCH 2/9] Create code snippet code --- .../code snippet | 1 + 1 file changed, 1 insertion(+) create mode 100644 Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet @@ -0,0 +1 @@ + From 6a14da7405224431769b238ee2a6a8c5493e560b Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 13:11:14 +0530 Subject: [PATCH 3/9] Update Readme.md --- .../Readme.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md index d95f3ad14d..1a9629b623 100644 --- a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md @@ -1 +1,5 @@ -content +Recent Request Autofill for ServiceNow Catalog.it automatically offers to fill in fields based on the user's most recent similar request. + + + + From 20405e807160646420921ae2d486e4df09f1fb37 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 14:25:25 +0530 Subject: [PATCH 4/9] Update and rename code snippet to Auto fill script include --- .../Auto fill script include | 30 +++++++++++++++++++ .../code snippet | 1 - 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include delete mode 100644 Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include new file mode 100644 index 0000000000..c4a343c99e --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include @@ -0,0 +1,30 @@ +var GetRecentRequestValues = Class.create(); +GetRecentRequestValues.prototype = Object.extendsObject(AbstractAjaxProcessor, { + getValues: function() { + var userID = this.getParameter('sysparm_user'); + var itemID = this.getParameter('sysparm_item'); + var result = { found: false, values: {} }; + + var gr = new GlideRecord('sc_req_item'); + gr.addQuery('requested_for', userID); + gr.addQuery('cat_item', itemID); + gr.orderByDesc('sys_created_on'); + gr.setLimit(1); + gr.query(); + + if (gr.next()) { + result.found = true; + + + var vars = gr.variables; + result.values = { + 'requested_for': vars.requested_for + '', + 'location': vars.location + '', + 'department': vars.department + '' + }; + } + + return JSON.stringify(result); + } +}); + diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet deleted file mode 100644 index 8b13789179..0000000000 --- a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/code snippet +++ /dev/null @@ -1 +0,0 @@ - From 8de0fd0f8b7c1051ad93cf5e871dca375a3bcaf9 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 14:26:27 +0530 Subject: [PATCH 5/9] Create Client script Autofill --- .../Client script Autofill | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill new file mode 100644 index 0000000000..b030ddcca1 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill @@ -0,0 +1,27 @@ +function onLoad() { + var user = g_user.userID; + var itemID = g_form.getUniqueValue(); + + var ga = new GlideAjax('GetRecentRequestValues'); + ga.addParam('sysparm_name', 'getValues'); + ga.addParam('sysparm_user', user); + ga.addParam('sysparm_item', itemID); + ga.getXMLAnswer(function(response) { + var data = JSON.parse(response); + if (data && data.found) { + var confirmFill = confirm("We found a similar request. Do you want to autofill fields?"); + if (confirmFill) { + for (var field in data.values) { + if (g_form.getControl(field)) { + g_form.setValue(field, data.values[field]); + console.log("Set " + field + " to " + data.values[field]); + } else { + console.log("Field not found: " + field); + } + } + } + } else { + console.log("No previous request found."); + } + }); +} From b5e3bf47e25574ad97d74bec57fc1e1e1e044997 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 14:27:33 +0530 Subject: [PATCH 6/9] Update Readme.md --- .../Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md index 1a9629b623..caa76ccb08 100644 --- a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md @@ -1,5 +1,6 @@ Recent Request Autofill for ServiceNow Catalog.it automatically offers to fill in fields based on the user's most recent similar request. +image From f52478ce0385ae9668b000f63da86cf805ef7133 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 17:06:08 +0530 Subject: [PATCH 7/9] Update Readme.md --- .../Readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md index caa76ccb08..a90213b53a 100644 --- a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md +++ b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Readme.md @@ -1,4 +1,8 @@ Recent Request Autofill for ServiceNow Catalog.it automatically offers to fill in fields based on the user's most recent similar request. + Features +- Detects previous requests for the same catalog item +- Prompts user to reuse values from their last submission +- Autofills fields like location, department, and justification image From c9e3df148179facdae896fca30bc788c2feb70c6 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 17:31:29 +0530 Subject: [PATCH 8/9] Rename Client script Autofill to Client script Autofill.js --- .../{Client script Autofill => Client script Autofill.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/{Client script Autofill => Client script Autofill.js} (100%) diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill.js similarity index 100% rename from Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill rename to Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Client script Autofill.js From f344a02237ed5a2b7e63934becdc99fcbb3d9911 Mon Sep 17 00:00:00 2001 From: Maheshkh9738 Date: Fri, 17 Oct 2025 21:14:48 +0530 Subject: [PATCH 9/9] Rename Auto fill script include to Auto fill script include.JS --- .../{Auto fill script include => Auto fill script include.JS} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/{Auto fill script include => Auto fill script include.JS} (100%) diff --git a/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include b/Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include.JS similarity index 100% rename from Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include rename to Client-Side Components/Catalog Client Script/Autofilling the request details from previous request/Auto fill script include.JS