diff --git a/AbortDuplicates.js b/AbortDuplicates.js new file mode 100644 index 0000000000..1706abea0a --- /dev/null +++ b/AbortDuplicates.js @@ -0,0 +1,14 @@ +(function executeRule(current, previous /*null when async*/) { + + // Add your code here + + var gr=new GlideRecord('incident'); + gr.addQuery('caller_id',current.caller_id); + gr.addQuery('short_description','CONTAINS','email'); + gr.query(); + if(gr.next()){ + gs.addErrorMessage("You have already created the incident with the similar short description"); + current.setAbortAction(true); + } + +})(current, previous); diff --git a/Client-Side Components/Client Scripts/ChangeLocation/Location.js b/Client-Side Components/Client Scripts/ChangeLocation/Location.js new file mode 100644 index 0000000000..b879472016 --- /dev/null +++ b/Client-Side Components/Client Scripts/ChangeLocation/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/ChangeLocation/README.md b/Client-Side Components/Client Scripts/ChangeLocation/README.md new file mode 100644 index 0000000000..fb7dda4cdd --- /dev/null +++ b/Client-Side Components/Client Scripts/ChangeLocation/README.md @@ -0,0 +1,6 @@ +Script Type + +Client Script — onChange + +This is an onChange client script in ServiceNow that runs automatically whenever the user changes the value of the Location (u_location) field on a form. +It uses the reference value of that location to check its state and dynamically updates the Preferred Language (preferred_language) field options in real time — without needing to reload the form.