Categories:

Use GlideAjax in Service Portal in onSubmit Client Script

You are correct that you cannot use synchronous GlideAjax (getXMLWait()) in the Service Portal. 

Use the below code:

function onSubmit() {
	if (!g_form.ajaxComplete) {
		ajaxCall();
		return false;
	}
}

function ajaxCall() {
	var ga = new GlideAjax(script_include);
	ga.addParam("sysparm_name", function_name);
	ga.getXMLAnswer(function(a){
		// Do whatever you want to with the answer
		// Once you've handle the answer, run these two lines:
		g_form.ajaxComplete = true;
		g_form.submit();
	});
}

Total Views: 2930