diff --git a/Client-Side Components/Client Scripts/locationChange/Change Location.js b/Client-Side Components/Client Scripts/locationChange/Change Location.js new file mode 100644 index 0000000000..b879472016 --- /dev/null +++ b/Client-Side Components/Client Scripts/locationChange/Change Location.js @@ -0,0 +1,17 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || newValue === '') { + return; + } + + //Type appropriate comment here, and begin script below + + var loc=g_form.getReference('u_location').state; + alert(loc); + if(loc == 'CA'){ + alert("state is CA"); + g_form.addOption('preferred_language','africa','Africa'); + }else{ + g_form.removeOption('preferred_language','africa'); + } + +} diff --git a/Client-Side Components/Client Scripts/locationChange/README.md b/Client-Side Components/Client Scripts/locationChange/README.md new file mode 100644 index 0000000000..063c221a10 --- /dev/null +++ b/Client-Side Components/Client Scripts/locationChange/README.md @@ -0,0 +1,11 @@ +Dynamic Option Handling in ServiceNow Form (onChange Client Script) + +Usage +This script dynamically adds or removes a dropdown option based on the selected location’s state value. +When the location is in **California (CA)**, the option **"Africa"** appears in the **Preferred Language** field; otherwise, it is removed. + +Use Case +Useful when you want to control dropdown field options dynamically depending on values in other reference fields. + +Script Type +**Client Script** — `onChange` diff --git a/Server-Side Components/Script Includes/ProblemCreation/CreateProblem.js b/Server-Side Components/Script Includes/ProblemCreation/CreateProblem.js new file mode 100644 index 0000000000..1ccba94e71 --- /dev/null +++ b/Server-Side Components/Script Includes/ProblemCreation/CreateProblem.js @@ -0,0 +1,15 @@ + + (function executeRule(current, previous /*null when async*/) { + + // Add your code here +if(current.category == 'hardware'){ + var gr=new GlideRecord('problem'); + gr.initialize(); + gr.short_description=current.short_description; + gr.category=current.category; + gr.impact=current.impact; + gr.urgency=current.urgency; + gr.insert(); + +} +})(current, previous); diff --git a/Server-Side Components/Script Includes/ProblemCreation/README.md b/Server-Side Components/Script Includes/ProblemCreation/README.md new file mode 100644 index 0000000000..846004ab85 --- /dev/null +++ b/Server-Side Components/Script Includes/ProblemCreation/README.md @@ -0,0 +1,3 @@ +This script is a ServiceNow Business Rule that creates a Problem record whenever an Incident is created with the category "hardware". + +Note: Not every hardware-related incident requires a problem record — this script is just an example to show how such automation can be set up.