I want to not allow user to press order now until one of the field in catalog item is populated.

Taaha M
Tera Contributor

I do not want to allow user to press order now until one of the field in catalog item is populated.
I am struggling in client script where I have to only allow users to press order now until few fields gets populated.
How can I do that?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Taaha M 

there are 2 ways to handle this

1) you can use onSubmit catalog client script and check if that variable has value or not.

if not then stop form submission

function onSubmit(){
	if(g_form.getValue('variableName') == ''){
		g_form.addErrorMessage('Please fill the variable before submitting');
		return false;
	}
}

OR

2) You can mark that variable as mandatory always

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

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Taaha M 

there are 2 ways to handle this

1) you can use onSubmit catalog client script and check if that variable has value or not.

if not then stop form submission

function onSubmit(){
	if(g_form.getValue('variableName') == ''){
		g_form.addErrorMessage('Please fill the variable before submitting');
		return false;
	}
}

OR

2) You can mark that variable as mandatory always

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