- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 12:10 PM
If there are two Client Scripts below:
- Client Script 1
Set a value to clumn_a
- Client Script 2
Field Name :clumn_a
onChange
Set a value to clumn_b
I want to stop Client Script 2 from running when the value of clumn_a is changed in Client Script 1.
Is there any way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:11 PM
On first evaluation/thought, have a hidden intermediate boolean variable (clumn_a_changed) which is set to "true" if the value is set to "clumn_a" in client script 1 and start the second client script with an "if (clumn_a_changed == false) { script_stuff; } else { return; }" type of statement
what are you triggering your client script(s) on? if they trigger on the same thing, I think you'll need to set an order (I believe this is possible)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 02:11 PM
On first evaluation/thought, have a hidden intermediate boolean variable (clumn_a_changed) which is set to "true" if the value is set to "clumn_a" in client script 1 and start the second client script with an "if (clumn_a_changed == false) { script_stuff; } else { return; }" type of statement
what are you triggering your client script(s) on? if they trigger on the same thing, I think you'll need to set an order (I believe this is possible)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 08:17 PM
Thank you for your answer.
The trigger for Client Script 1 is clumn_c, and the trigger for Client Script 2 is clumn_a, which was set in Client Script 1.
I will try to use intermediate boolean variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 07:56 AM
glad I could help. just be sure to add the field to your form as a hidden field, you cannot just create the custom field on the table and have it accessible to a client script, it needs to be on the form to be set and referenced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 08:41 PM
why not merge both the client scripts and set value in column b?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader