Checkbox not setting to true due to Catalog Client srcipt???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:39 AM - edited 06-05-2024 05:45 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 05:57 AM - edited 06-05-2024 05:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 07:03 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 07:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 07:11 AM - edited 06-05-2024 07:19 AM
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