- 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:44 PM
i know what is happening but not sure how to tackle the problem. the code i have above is looking for the UI Action request approval if this one is presented on the form and my checkbox field is checked the request approval is removed. however if i save the form obvioulsy the request approval is not there anymore so if i uncheck the field this one it will still look for the name of the request approval and thats why is generating the issue i guess.
what i would have to do is to enclose my code in some kind a IF saying fiend the ui action reques approval if is found do what code says and if its not found dont do nothing.
but im not sure how to put this condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:47 PM
something like this however this is not working
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading|| newValue === '') {
return;
}
if (g_form.getElement(state_model_request_assess_approval)) // find ui action request for approval
{
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 {
if (g_form.getValue('u_vendor_change') == 'false' ) {
// document.querySelectorAll("#state_model_request_assess_approval")[0].show();
// document.querySelectorAll("#state_model_request_assess_approval")[1].show();
}}
}
any help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 12:53 PM
In that case, you should check that if the element is present in the page then only it should show/hide, for example :
if(jQuery("[id=state_model_request_assess_approval]").length == 2) {
console.log("UI action found");
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:55 PM
Also, this is runtime exception, you should use "try - catch" to deal with this kind of issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2017 01:01 PM
do you know how can i add that on my code