Is there any way to call script include synchronously from service portal other than getXMLWait()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 01:34 AM
Hi All,
Is there any way to call script include synchronously from service portal other than getXMLWait()?
I am using getXMLWait() in onSubmit client scripts.
Thanks in advance.
Prateek Gupta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 01:02 AM
As the Service Portal is based on Angular I am wondering why you would need an Ajax Call separately. Shouldn't you just use the client / controller piece of Angular?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:49 AM
Hi Chuck/ Fogg,
I'm also facing same issue, my onsubmit client script also not working due to getxmlwait in service portal. Its working in ServiceNow but in portal i'm getting java console error.
OnSubmit client script:
function onSubmit() {
if(g_form.getValue('field name') == 'Yes'){
var ga = new GlideAjax('xxxxx');
ga.addParam('sysparm_name','attachmentExists');
ga.addParam('sysparm_record_id',g_form.getValue('sysparm_item_guid'));
ga.getXMLWait();
var attachment = ga.getAnswer();
if(attachment == "false"){
g_form.addErrorMessage(getMessage("message1"));
g_form.addInfoMessage(getMessage("messsgae2"));
return false;
}}}
Script include:
var xxxxx = Class.create();
CheckAttachment.prototype = Object.extendsObject(AbstractAjaxProcessor, {
attachmentExists: function() {
var attachmentGR = new GlideRecord('sys_attachment');
var record_id = this.getParameter('sysparm_record_id');
attachmentGR.addQuery("table_sys_id", record_id);
attachmentGR.query();
if(attachmentGR.next()) {
return true;
}
return false;
},
type: 'xxxxx'
});
Could you pls urgent help how it will work, I tried lot of things but its not working in Portal page. Thanks, Mehak

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 12:41 AM
Hi,
Use below client script:
function onSubmit() {
if(g_form.getValue('field name') == 'Yes'){
var ga = new GlideAjax('xxxxx');
ga.addParam('sysparm_name','attachmentExists');
ga.addParam('sysparm_record_id',g_form.getValue('sysparm_item_guid'));
ga.getXML(callback);
function HelloWorldParse(response) { var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == "false"){
g_form.addErrorMessage(getMessage("message1"));
g_form.addInfoMessage(getMessage("messsgae2"));
return false;
}
}
}
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 10:53 PM
You can write before/insert business rule and after GlideRecord use current.setAbortAction(true);.