onSubmit Catalog Client script not working in Service portal

Bargavi
Mega Expert

Hi,

There is a field "App Code" in one of the catalog items which has a validation to check if the user is entering already existing app code, in case he is entering the existing one it should alert   "Requested app code already exists choose a different one".

I am using the below script:

var ui_app_code = g_form.getValue('u_requested_app_code');
var gr = new GlideRecord('cmdb_ci_appl');
gr.addQuery('u_application_code', ui_app_code);      
gr.query();

while(gr.next())
{

alert (" Requested App code already exists. Please choose a different one...");
return false;
}
}

If I am trying to submit the catalog item using the existing app code from an ESS page I have an alert and the form does not get submitted but the same is not working in service portal. can some one help me on what modifications has to be done to the code to make it work in service portal.

Thanks,

Bargavi

1 ACCEPTED SOLUTION

Bargavi
Mega Expert

was able to resolve it using thread Catalog Client Script asyncrhonous query to stop submission onSubmit.



Thanks for replying



-Bargavi


View solution in original post

12 REPLIES 12

Brad Tilton
ServiceNow Employee
ServiceNow Employee

On the catalog client script make sure you have the UI Type field set to mobile or both and not desktop.



documentation/client_scripting.md at master · service-portal/documentation · GitHub


Hi Brad,



I already have the UI type for Both selected in Catalog Client Script.



Thanks,


Bargavi


parameswar
ServiceNow Employee
ServiceNow Employee

Hi,


Please check your browser javascript console for errors.. that can give some clue..


Hi Parameswar,



There are no errors in console .



Thanks,


Bargavi