Return false is not working in catalog client script i scoped application

lucky24
Tera Contributor

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.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@lucky24 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@lucky24 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

@lucky24 

what came in alert for that variable value?

Did you set UI Type - ALL?

Is the onSubmit script active?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader