Multiple fields with onChange

tbalestreri3
Mega Contributor

I am using client scripts to set the incident state on my forms. This is working great however I do have one question.

One of my conditions is based off of if several fields change. I cannot use the modified function because there are some fields I do not want this to apply to. Is there a way you could apply onChange to multiple fields without making a separate client script?


If am example helps this is a single client script of mine...



function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if(newValue != '') {
//Type appropriate comment here, and begin script below
var state;
state = g_form.getValue('incident_state');
//alert("state = " + state);

if(state == '210' || state == '220'){
g_form.setValue('incident_state', '230');
}
}
}
}

Thanks,
Tony

15 REPLIES 15

Josh,



From the time I designed it, calculateDuration could be a few things. The calculateDuration function as I may have written it, may have been included in a UI Script which is then placed on the form (like a field would be) using Macro (UI Macro) and Formatters.



If you look under UI Scripts and search the sys_ui_script.script field for the string "calculateDuration", you may be able to find it buried within a script that includes a set of functions that pertains to a specific form (e.g. Requested Item form, Task Scheduler form, etc.).



This was my way of including a bunch of client-side functions that I could call at will within the form, written all in one inclusive place.



If you can't find it in there, let me know. I will need to look at a developer's instance to see where else it may be.



calculateDuration function does, in fact, call the Script Inlcude (server call) to get the value back so it is written client-side somewhere, if not where I just stated.


Found it.   Thanks!


patshah
Kilo Contributor

I know this post is pretty outdated, but it is also the first to show up on google and I feel that the solution I found below solved this issue very easily for me:



http://www.snc-blog.com/2012/06/04/client-script-for-multiple-fields/


sonu16
Giga Contributor

This worked for me perfectly.


nz1
Kilo Contributor

This failed in Quebec, any experience with that?