OnSubmit Client Script not working in ServicePortal

Shahebaz2
Kilo Contributor

Hello Experts, 

I want to understand how could we use the below script in catalog client script.

1  function onSubmit() {
2 if (g_scratchpad.isFormValid)
3 return true;
4 var actionName = g_form.getActionName();
5 doAsyncTask(function() {
6 g_scratchpad.isFormValid = true;
7 g_form.submit(actionName);
8 });
9 return false;
10 }

when I am using I got this error

onSubmit script error: ReferenceError: g_scratchpad is not defined:
function () { [native code] }

I am referring to this article -  https://hi.service-now.com/kb_view.do?sysparm_article=KB0779964 where the above solution mentioned.

how g_scratchpad.isFormValid is configured on catalog form?

Your comments would be apricated.

Thanks

8 REPLIES 8

Can you share prints screen of the onsubmit script configuration?

Have you looked at my article? It gives a more elaborate example and explains how to use.

Shahebaz2
Kilo Contributor

Hello Willem,

I looked into your article very nice explanation. but I have a question, How did you configured g_scratchpad.isFormValid in catalog client script. please explain this. 

Thanks,

It is available for Catalog Client script of UI Type service portal/mobile OOTB. You do not have to set up anything additional.