diff --git a/Client-Side Components/Client Scripts/Change Label of Field/Change label of Field.js b/Client-Side Components/Client Scripts/Change Label of Field/Change label of Field.js new file mode 100644 index 0000000000..985c0ff866 --- /dev/null +++ b/Client-Side Components/Client Scripts/Change Label of Field/Change label of Field.js @@ -0,0 +1,11 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + // Prevent execution when the form is loading... + if (isLoading || newValue == oldValue) return; + + // Update Description field label based on Priority + if (newValue == '1') { + g_form.setLabelOf('description', 'Describe the critical issue in detail'); + } else { + g_form.setLabelOf('description', 'Description'); + } +} diff --git a/Client-Side Components/Client Scripts/Change Label of Field/Readme.md b/Client-Side Components/Client Scripts/Change Label of Field/Readme.md new file mode 100644 index 0000000000..ac575c949a --- /dev/null +++ b/Client-Side Components/Client Scripts/Change Label of Field/Readme.md @@ -0,0 +1,32 @@ +Dynamic Field Label Change in ServiceNow +Overview + +This script is created for the Incident table to change the Description field label when the Priority field value changes. + +When the Priority is set to 1 (Critical), the Description label becomes +“Describe the critical issue in detail” to help users give more clear information. +For all other priorities, it goes back to “Description.” + +Setup Steps: + +Go to System Definition → Client Scripts → New + +Fill in the following details: + +Name: Change Description Label Based on Priority + +Table: Incident + +UI Type: All + +Type: onChange + +Field name: Priority + +Notes + +Works only on the Incident form when the Priority field is changed. + +The label updates immediately without reloading the form. + +You can change the label text to fit your own use case.