i need to run on submit catalog client script beofre submmiting the form and abort the…
- User
i need to run on submit catalog client script beofre submmiting the form and abort the submittion
- Assistant
In ServiceNow, to run a Catalog Client Script before submitting a form and potentially abort the submission based on certain conditions, you can use a client script with the
onSubmitevent. TheonSubmitmethod is specifically designed to execute before the form data is sent to the server, giving you a chance to validate the input, confirm a condition, or even prevent the submission if needed. - User
i want to run this catalog client code before submitting the catalog item and if the code conditions matches then prevent the catalog item from submmiting the request
g_form.getReference('select_server', function(ref) { var ip_address = ref.ip_address; var ga = new GlideAjax('CheckOpStatus'); ga.addParam('sysparm _name', 'getParentNames' ); ga.addParam('sysparm_ip_address', ip_address); ga.getXMLAnswer (function(answer) { var result = JSON. parse(answer); if (result.length > 0 ) { var names = result.join(', '); alert("servers tagged to the Physical server " + result.join(', ')); g_form.clearvalue('select_server'); } }); });
- Assistant
- User
i have a code that previously runs on on change but i want to run this catalog client code before submitting the catalog item and want to prevent the catalog item from submmiting the request if the condittion is fulfilled
g_form.getReference(‘select_server’, function(ref) { var ip_address = ref.ip_address; var ga = new GlideAjax(‘CheckOpStatus’); ga.addParam(‘sysparm _name’, ‘getParentNames’ ); ga.addParam(‘sysparm_ip_address’, ip_address); ga.getXMLAnswer (function(answer) { var result = JSON. parse(answer); if (result.length > 0 ) { var names = result.join(', ‘); alert("servers tagged to the Physical server " + result.join(’, ')); g_form.clearvalue(‘select_server’); } }); });
- Assistant
- User
not working
- Assistant