The CreatorCon Call for Content is officially open! Get started here.

change GlideAjax method from GetXML() to GetXMLWait()

sureshp89882164
Tera Contributor
Scenario is: A 'Pop-Up' message will appear on-screen when any end-user attempts to re-assign (more than one time) already assigned incident to the Technical Service Desk (TSD).
 
Which one is the best one either using with GetXML() OR GetXMLWait()
Currently using with GlideAjax method GetXML(), what changes i have to do if I change from GetXML() to GetXMLWait() on below code:
 
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
 var ga = new GlideAjax('assignmentCountincident');
    ga.addParam('sysparm_name', 'getIncidentCount');
    ga.addParam('sysparm_inc_sysid', g_form.getUniqueValue());
    ga.getXML(responseParse);

 

function responseParse(response){
    var answer = response.responseXML.documentElement.getAttribute("answer");
    if ((answer>=1) && (newValue == 'f1bb47cadb2e83008449f6e9bf96190f')){
       
alert('Incidents are not to be reassigned back to TSD for resolution, customer call back and/or further team re-assignment. );

 

}
}
}
 
script include: assignmentCountincident
 
6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@sureshp89882164 

remember getXMLWait() won't work on portal as it's not allowed as it's synchronous.

You can continue using getXML() which works in native + portal and is asynchronous.

getXMLWait() is synchronous and makes sense to use when next action is dependent and should wait till response comes from Script Include.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

M Iftikhar
Giga Sage

 

Hi @sureshp89882164,

You should keep using getXML(). It’s asynchronous, works in both native UI and Service Portal, and keeps the interface responsive.

getXMLWait() is synchronous, freezes the UI, and isn’t supported in Service Portal, so it’s not recommended.

Your current script with the responseParse callback is the correct and safe approach for this scenario.



Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.