From 663294143848ead83fe0251237a5bfa02a0fcaa4 Mon Sep 17 00:00:00 2001 From: Sai Charan Koratala Date: Wed, 1 Oct 2025 11:22:27 +0530 Subject: [PATCH 1/2] Create getFormElements.js This code helps in retrieving all the form fields by getting all the elements on the form --- .../Client Scripts/Get Form Elements/getFormElements.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Get Form Elements/getFormElements.js diff --git a/Client-Side Components/Client Scripts/Get Form Elements/getFormElements.js b/Client-Side Components/Client Scripts/Get Form Elements/getFormElements.js new file mode 100644 index 0000000000..1b8f7c7ea1 --- /dev/null +++ b/Client-Side Components/Client Scripts/Get Form Elements/getFormElements.js @@ -0,0 +1,8 @@ +function onLoad() { + //Type appropriate comment here, and begin script below + var arr = []; + for (var i = 0; i < g_form.elements.length; i++) { + arr.push(g_form.elements[i].fieldName); + } + alert("Hi Sai, please find the form elements: " + arr.join(",")); +} From 39652239b06d8b8ced0df77e03b0ab07f15a1def Mon Sep 17 00:00:00 2001 From: Sai Charan Koratala Date: Wed, 1 Oct 2025 11:26:48 +0530 Subject: [PATCH 2/2] Create README.MD Readme file describing the functionality of the script --- .../Client Scripts/Get Form Elements/README.MD | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Get Form Elements/README.MD diff --git a/Client-Side Components/Client Scripts/Get Form Elements/README.MD b/Client-Side Components/Client Scripts/Get Form Elements/README.MD new file mode 100644 index 0000000000..82da81e2e0 --- /dev/null +++ b/Client-Side Components/Client Scripts/Get Form Elements/README.MD @@ -0,0 +1,3 @@ +This script is a Client Script (onLoad) for ServiceNow which retrieves all field names present on the current form and displays them in an alert message. + +Example: Hi Sai, please find the elements of the form short_description, description, number, etc.