- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:03 PM
i have created a field (checkbox) on change form and its doing the following when is set to true is taking away the request apporval action both the one from the top of the form and the one at the bottom of the form using this code
client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading|| newValue === '') {
return;
}
if (g_form.getValue('u_vendor_change') == 'true' ) {
document.querySelectorAll("#state_model_request_assess_approval")[0].hide();
document.querySelectorAll("#state_model_request_assess_approval")[1].hide();
}
else {
document.querySelectorAll("#state_model_request_assess_approval")[0].show();
document.querySelectorAll("#state_model_request_assess_approval")[1].show();
}
}
when is click save is saving the changes, however if i want to set to false again the checkbox is displaying an error message
does anyone know what i am doing wrong
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 01:07 PM
Here is a try/catch code with your script :
try{
if (g_form.getValue('u_vendor_change') == 'true' ) {
document.querySelectorAll("#state_model_request_assess_approval")[0].hide();
document.querySelectorAll("#state_model_request_assess_approval")[1].hide();
}
else {
document.querySelectorAll("#state_model_request_assess_approval")[0].show();
document.querySelectorAll("#state_model_request_assess_approval")[1].show();
}
}catch(error) {
console.log("Error on vendor change script "+error);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:08 PM
Hi,
Can you please check that "state_model_request_assess_approval" ID is present on HTML form or not ? and also please update .hide() with style.display = "none";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:12 PM
yes the state_model_request_assess_approval is presented on the form. i just change the code but still getting the error
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading|| newValue === '') {
return;
}
if (g_form.getValue('u_vendor_change') == 'true' ) {
document.querySelectorAll("#state_model_request_assess_approval")[0].style.display = "none";
document.querySelectorAll("#state_model_request_assess_approval")[1].style.display = "none";
}
else {
document.querySelectorAll("#state_model_request_assess_approval")[0].show();
document.querySelectorAll("#state_model_request_assess_approval")[1].show();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:29 PM
I think, the issue is that - you are trying to hide multiple elements by same ID using querySelectorAll.
querySelectAll can be use for "Class".
Can you please try below script :
jQuery("[id=state_model_request_assess_approval]").hide();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:33 PM
Have you tried using g_form.setDisplay? Displays field if true, hides field if false. I'm not sure what version you are on, but it is discouraged to use DOM manipulation, as it may not be compatible with future upgrades.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//If the page isn't loading
if (!isLoading) {
//If the new value isn't blank
if (newValue != '') {
g_form.setDisplay('priority', false);
}
else
g_form.setDisplay('priority', true);
}
}
Thanks,
Laurie
Please mark Correct, Helpful, or Like as applicable!