How to define and call a shared client-side function

kevinharalson
Mega Expert

I have a 3 fields on a table's form needing to run a snippet of code when the field's value changes. The snippet obtains the necessary information from the form, and executes a GlideAjax call.

Is there any way to define this snippet of code as a client-side function for the table so the code does not have to be replicated and maintained within 3 separate onChange client scripts?

Currently:

Field 1 onChange - obtains form data and makes ajax call

Field 2 onChange - obtains form data and makes ajax call

Field 3 onChange - obtains form data and makes ajax call

Desire:

Field 1 onChange - call client-side function

Field 2 onChange - call client-side function

Field 3 onChange - call client-side function

client-side function - obtains form data and makes ajax call

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi,

There is one option to include your reusable client script along with an onLoad client script. These scripts are accesible within onChange client scripts.

You can try this out once

function onLoad(){
}

function myReusableScript(){
alert("I am in");
}

function onChange(){
myReusableScript();
}

 

 

View solution in original post

6 REPLIES 6

Alikutty A
Tera Sage

Hi,

There is one option to include your reusable client script along with an onLoad client script. These scripts are accesible within onChange client scripts.

You can try this out once

function onLoad(){
}

function myReusableScript(){
alert("I am in");
}

function onChange(){
myReusableScript();
}

 

 

Or else you could use UI Scripts which act as reusable client side scripts.

Thank you. This worked exactly as I had hoped.

thanks