Checkbox not setting to true due to Catalog Client srcipt???

Community Alums
Not applicable

I encountered an issue that when a checkbox is set to true and there's an onChange client script that set the same checkbox to read only, the checbox is not being set to true instead it's only being read only. Is this an expeccted behavior?

 

Thank you.

4 REPLIES 4

AshishKM
Kilo Patron
Kilo Patron

Hi @Community Alums , 

Please share that client script, you need to set value & read-only status both because the onChange event on the same field which is going to be read only and now allowing to update. 

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Community Alums
Not applicable

Hi @AshishKM ,

 

We have an onChange client script that calls an integration and returns the value to true or false. When the return is true, it sets all the fields to read only. We tried replicating the issue in a much simpler client script (please see below) and still issue exist.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	if (newValue) {
		g_form.addInfoMessage("test checkbox is true");
		g_form.setReadOnly('test', true);
	}
   
}

 

VeeJayRecana1_0-1717596179926.png

 

As I understood, you can calling an intgration via onChange event which is actually a client side, and checkbox value not saved during the integration call/return and when return it true ..then other logic is setting all values read-only and previously checked value lost. 

 

try this updated code

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
	if (newValue) {
		g_form.addInfoMessage("test checkbox is true");
		g_form.setValue('test', true);
		g_form.setReadOnly('test', true);
	}
   
}

 

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Amitoj Wadhera
Kilo Sage

Hi @Community Alums ,

 

Corrected Script:

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   
   if (newValue) {
      g_form.addInfoMessage("test checkbox is true");
      g_form.setValue('test', true);   
      // Use setTimeout to ensure the value is set before making it read-only because you have a integration in place
      setTimeout(function() {
         g_form.setReadOnly('test', true);
      }, 100); // Adjust the delay time if necessary
   }
}

 

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Thanks,

Amitoj Wadhera