OnChange Script triggering when page loads or Change advances states.

ZacharyW
Tera Expert

Hello,

I am trying to populate Description and Short Description based upon a list of form choices.

If a user selects "Server Reboot" the following basic information needs to populate.

I have the following script, which populates a these fields when a use changes values. The problem I'm running into is that the value changes when the page refreshes or the change progresses to the next state. Does anyone have any advice?

find_real_file.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   
	newValue = g_form.getValue('u_quick_change_type');
	

	
							   
	if (newValue == 'menlo whitelist') {
     
	  
	   
	   g_form.setValue('short_description', 'Menlo Whitelist Add');
	   g_form.setValue('description', 'URL:  \nReason For Change:');
	   
	  
   }
   
	else if (newValue == 'server reboot') {
     
	   g_form.setValue('short_description', 'Server Reboot [Enter Server Name]');
	   g_form.setValue('description', 'Servername:  \nReboot Reason:');
	   
	 
   }
	
	else if (newValue == 'firewall port open') {
     
	   g_form.setValue('short_description', 'Firewall Port Open');
	   g_form.setValue('description', 'Source Port:  \nDestination Port:\nApplication Type:');
	   
	   
   }
	
	else if (newValue == 'firewall port close') {
     
	   g_form.setValue('short_description', 'Firewall Port Close');
	   g_form.setValue('description', 'Source Port:  \nDestination Port: \nApplication Type:');
	   
	  
   }
	
	
}
1 ACCEPTED SOLUTION

Manish Vinayak1
Tera Guru

Add the following line as the first line of your client script for not allowing it to run on load:

 

if(isLoading) {

return;

}

 

View solution in original post

9 REPLIES 9

Mike Patel
Tera Sage

Check Onchange field and type is set correctly on client script. Can you share full screenshot of client script.

Manish Vinayak1
Tera Guru

Add the following line as the first line of your client script for not allowing it to run on load:

 

if(isLoading) {

return;

}

 

This did the trick! Thank you so much!

Glad that it worked 🙂

Cheers,

Manish