- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 12:23 AM
I have a issue with my client script. It is working as expected in native UI but not in workspace.
UI Type is "ALL" & Isolate script is checked to "True"
Client Script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 02:33 AM
hi @Sanchita02 ,
can you try below code
function onSubmit() {
//Type appropriate comment here, and begin script below
var currentAttribute = (g_form.getValue('u_type_of_attribute'));
var currentApplication = (g_form.getValue('u_application'));
var curremtMF = (g_form.getValue('u_member_firm'));
var currentTitle = (g_form.getValue('u_title'));
var checAttributes = new GlideAjax("x_kpm94_ce.GQRM_Client_Evaluation_ClientUtils");
checAttributes.addParam('sysparm_name', 'checkduplicateAttribute');
checAttributes.addParam('sysparm_attribute', currentAttribute);
checAttributes.addParam('sysparm_application', currentApplication);
checAttributes.addParam('sysparm_memberfirm', curremtMF);
checAttributes.addParam('sysparm_title', currentTitle);
checAttributes.getXML(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
return false;
} else {
g_form.setValue('submit_flag', true); // Indicate that the form can be submitted
// Optionally submit the form or allow the default behavior
} });
}
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 02:50 AM
Hi @Sanchita02
From your script you will figure out this error message under the browser console.
GlideAjax.getXMLWait is no longer supported
More important, the GlideAjax (Asynchronous) does not work on onSubmit Client Script. This is because of the fundamental behavior of Asynchronous scripts which are non-blocking by nature. So the form will get submitted before the response returning.
Let's try this approach below.
Ref: Onsubmit catalog client script is not aborting the form from submitting.
KB. KB0783579
Cheers,
Tai Vu