- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:06 AM
HI Team,
I have one checkbox variable on catalog item if this is true and I have to restrict user to submit the form for that I have written catalog client script like below but this is not working as expected.
function onSubmit() {
//Type appropriate comment here, and begin script below
var not_available = g_form.getValue("not_available");
alert(not_available);
if(not_available == true){
//g_form.addErrorMessage("Test");
return false;
}else{
return true;
}
}
Please help me here.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:10 AM
try this once. I consider the checkbox variable is not within a MRVS
function onSubmit() {
//Type appropriate comment here, and begin script below
var not_available = g_form.getValue("not_available");
alert(not_available);
if(not_available.toString() == 'true'){
//g_form.addErrorMessage("Test");
return false;
}else{
return true;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:10 AM
try this once. I consider the checkbox variable is not within a MRVS
function onSubmit() {
//Type appropriate comment here, and begin script below
var not_available = g_form.getValue("not_available");
alert(not_available);
if(not_available.toString() == 'true'){
//g_form.addErrorMessage("Test");
return false;
}else{
return true;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:33 AM
Hi Ankur,
I tried with your code but still I am able to submit the request and my checkbox variable is not in MRVS.
function onSubmit() {
//Type appropriate comment here, and begin script below
var not_available = g_form.getValue("not_available");
alert(not_available);
if(not_available.toString() == 'true'){
//g_form.addErrorMessage("Test");
return false;
}else{
return true;
}
}
Thanks for your response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:37 AM - edited 11-06-2023 06:38 AM
what came in alert for that variable value?
Did you set UI Type - ALL?
Is the onSubmit script active?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader