Can we change onChange client script into onLoad?

Ashwini Jadhao
Giga Guru

hi,

How to change onChange client script into onLoad client script?

 

 

 

1 ACCEPTED SOLUTION

Service_RNow
Mega Sage

HI Ashwini,

if you need to Onchange client script is behavior like Onchange as well as onload -:

do the simple change in if condition remove the isLoading || 

eg.

function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
//put your code here 
return;
}
}

Thanks

 

View solution in original post

8 REPLIES 8

You need to do this changes only

Default:

if (isLoading || newValue == '')

Change it to

if (newValue == '')

It will run when the form is loading.

This is the actual need to do it.

An onLoad script will work when a form loads, it might be dependent on value of a field or some other condition.

For instance, If I hide Close Notes section for states other than Resolved & Closed, I will use an onLoad Script.
OnChange is always used when I want to change value of a field based on value of other field on the go.. So, If I want to give an alert box to user when he changes priority to 1, I would use onCHange

 

Mark it correct or helpful, If it helps you.

Hey Ashwini, at times some functionalities or validations require to run ON LOAD and ON CHANGE at the same time, so instead of creating separate client scripts for ON CHANGE and ON LOAD we can create it in one ON CHANGE script by using this method

function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
//your_code
return;
}
}

Service_RNow
Mega Sage

HI Ashwini,

if you need to Onchange client script is behavior like Onchange as well as onload -:

do the simple change in if condition remove the isLoading || 

eg.

function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
//put your code here 
return;
}
}

Thanks