GlideAjax Client Script not working in Agent Workspace

PavelP
Mega Sage

Hello, 

our customer is trying to start using Agent Workspace for Incident Management. Currently, the Priority of incident is being calculated via Client-script, so anytime the urgency/priority changes, its updated on the form in real time. This however is not working on the Agent Workspace.

Script include is allowed to run in all applications. See here the Client script code.

find_real_file.png

Do you have any idea, if there is an issue in the code that may cause it, or recomendation, how to fix the issue?

Thank you in advance

Best regards

Pavel

1 ACCEPTED SOLUTION

As for the original problem, I'm guessing in Platform UI there was something in place, perhaps a global UI Script or a plain onLoad Client Script that loaded function calcReturn0 globally, method that is not working in Experience/Agent Workspace. You should find out how it was loading, where it is defined and copy it with dependencies - if there are any, into this onChange Client Script.

But I do wonder, can't Priority Lookup be used here?

View solution in original post

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

Hi @PavelP 

at the end some important code is missing. Where is the method "calcReturn0" and why there are additional two paramneters? (see https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideAjaxAPI#r_GLAX-getXML_S)

Kind regards
Maik

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Hi Maik,

this is how the code was before I got to it, and it was - and still is - working in the backend. From what I understand it, it's from the older version of the instance, and its used there to calculate the priority.

I didn't understand it either so I tried to avoid changing it - as it worked on the regular form as intended. However on the AW, the call from Client Script doesn't go through.

As for the original problem, I'm guessing in Platform UI there was something in place, perhaps a global UI Script or a plain onLoad Client Script that loaded function calcReturn0 globally, method that is not working in Experience/Agent Workspace. You should find out how it was loading, where it is defined and copy it with dependencies - if there are any, into this onChange Client Script.

But I do wonder, can't Priority Lookup be used here?

Re. additional two parameters: because the "real" signature of the function is:

getXML(callback, additionalParams, responseParams)

Just like getXMLAnswer.

The 2nd parameter - as far as I know should be on object literal where the property names will be the parameter names and the property values the parameter values. Will be collated with parameters defined the known way, by calling addParam().

Thus

var gx = new GlideAjax('SI');

gx.addParam('sysparm_name', 'method');
gx.addParam('sysparm_test', 'Abc123Zyx098');

gx.getXMLAnswer(printAnswer);

function printAnswer (answer) {
	console.log(a);
}

and

var gx = new GlideAjax('SI');

gx.getXMLAnswer(printAnswer, { 'sysparm_name': 'method', 'sysparm_test': 'Abc123Zyx098', });

function printAnswer (answer) {
	console.log(a);
}

will act the same.
getXML works the same, just that the answer is not a string, but an XML document.

The 3rd parameter is the same as for getXMLAnswer.

Not sure if this applies only to Platform UI or Portal too.