In incident if a state is change from in progress to on hold hide the description field…
- User
In incident if a state is change from in progress to on hold hide the description field in servicenow
- Assistant
In incident if a state is change from in progress to on hold hide the description field in servicenow
To implement functionality in ServiceNow that automatically hides the description field when an incident's state changes from "In Progress" to "On Hold", you can achieve this by using Client Scripts. Client Scripts in ServiceNow enable you to execute JavaScript on the client side (i.e., in the user's browser) to dynamically change form behaviors.
For your specific case, a "onChange" client script is suitable, as you want to hide a field based on the change of another field's value.
Here is a general guide on how to create such a client script:
Navigate to System Definition > Client Scripts
Create New Client Script
Fill in the relevant fields:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Here "4" is often the state code for "On Hold" in the Incident table; this may vary
// Check your instance's state field values if different.
if (newValue == '4') { // Assuming "4" is the value for "On Hold" state
g_form.setDisplay('short_description', false); // Hide the description field
} else {
g_form.setDisplay('short_description', true); // Show the description field
}
}
Active: Ensure that you check this box to enable the client script.
Submit the form to save and enable your script.
Important Considerations:
This JavaScript code checks if the state changes to "On Hold" (adapt the state value as needed) and uses g_form.setDisplay('short_description', false); method to hide the short_description field. Ensure that the field names ('state' and 'short_description') correspond correctly to those in your ServiceNow configuration, as customizations might use different field names.