How to fix the OnChange Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 12:56 AM
Hi All ,
I have written the below onchange client script for impact field ,
the requirement is .. whenever an Incident form is opened there is some default value for the impact field on the Incident form being setup .. so if the customer changes the default value of the Impact field before clicking on the SAVE button on the Incident during that time the worknotes should not be mandatory which is working perfectly fine with the below code .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 01:48 AM
If you change impact from 1 to 3 and then 3 to 1 without submitting the form that means No changes have been made according to your clientScript. As the newValue will become OldValue it means that the specific Onchange condition is not meeting. The Onchange Client script will execute when oldValue is not equal to newValue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 01:54 AM
Hi @Sumit Pandey3 - how to fix the above code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 05:52 AM
Hi @Pooja Khatri , The Above code is fine. Try to understand the OnChange client script as a concept. I can share with you a solution if you'd like more about the requirements and what you're trying to achieve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 02:16 AM
Hi @Pooja Khatri ,
Please try to understand what @Sumit Pandey3 has mentioned, your script is fine please test it correctly, oldvalue should not be same as newvalue to make work notes mandatory.
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************