Skip to content

Commit fded483

Browse files
authored
Get form elements using client script (#1648)
* Create getFormElements.js This code helps in retrieving all the form fields by getting all the elements on the form * Create README.MD Readme file describing the functionality of the script
1 parent c4bf84d commit fded483

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
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.
2+
3+
Example: Hi Sai, please find the elements of the form short_description, description, number, etc.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function onLoad() {
2+
//Type appropriate comment here, and begin script below
3+
var arr = [];
4+
for (var i = 0; i < g_form.elements.length; i++) {
5+
arr.push(g_form.elements[i].fieldName);
6+
}
7+
alert("Hi Sai, please find the form elements: " + arr.join(","));
8+
}

0 commit comments

Comments
 (0)