onChange client script with templates and dependent choice lists

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2014 02:26 PM
I have a couple of onChange client scripts that run when the category and subcategory of an incident change.
What I am needing to do is exclude these from running when a template changes either one of these fields.
It looks as if an onChange client script set to a dependent choice list will fire twice, once when the parent choice is made (I assume by the setting of the choices) and once when the field itself is changed.
Because of this, I am only able to stop one 'cycle' of the script by using the isTemplate check.
How can I stop the client script from running the second time on the subcategory field when a template is used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2014 05:11 PM
I hope that I understood your problem correctly, because I tried duplicating your error on a Eureka version (ServiceNow) by putting a client script with an alert on the subcategory. Then I changed the category and the script did not run.
Might something in your script be causing it to run twice? I can't really evaluate it without seeing your script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2014 08:44 AM
Here is my onChange script for the subcategory field that I am using as a test case.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '' || isTemplate) {
return;
}
alert("subcat fired");
}
If I use a template that sets the category and subcategory, I get the alert.
If I use a template that only sets either the cat or subcat, I do not get the alert.
This only seems to occur when I am setting both values.
In my tests on a demo site, I was able to duplicate if my template was setting both values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2014 10:22 PM
Hi,
I think you need to check for template in subcategory onchange script also.
If it's not help you please provide your script and scren short of you page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2014 01:05 PM
Yes, it makes sense to check for a template in both.