Unable to call Ui script in Workspace ui action level

pavanmallur
ServiceNow Employee

Please find the workspace ui script

function logTelemetry(status) {
g_ui_scripts.getUIScript('UIActionPerformanceLoggerClient').then(function(perfLogger) {
var executionTime = new Date().getTime() - start;
perfLogger.logTime("Budgetary Quote: ", executionTime, status, g_form.getValue("number"));
});
}

Ui script :
 

var UIActionPerf = (function() {
function logTime(action, ms, status, number) {
var gaLog = new GlideAjax('UIActionPerformanceLogger');
gaLog.addParam('sysparm_name', 'logTime');
gaLog.addParam('sysparm_action', action);
gaLog.addParam('sysparm_time', ms);
gaLog.addParam('sysparm_status', status);
gaLog.addParam('sysparm_record', number);
gaLog.getXML();
}
 
return {
logTime: logTime
};
})();


Same script is working as expect in dev instance when comes to QA it is failing saying that
TypeError: Cannot read properties of null (reading 'logTime')
at eval (eval at get (GlideScopedScript.js:49:27), <anonymous>:9:24)
2 REPLIES 2

k_lutz
Giga Sage

Hi @pavanmallur 

 

Are you sure they are the same? From above it says the type is "Desktop". According to the SN documentation:

https://www.servicenow.com/docs/r/api-reference/GUIScriptsAPI.html

 

It can either be All or Mobile/Service portal but not Desktop.

 

Tanushree Maiti
Giga Patron

Hi @pavanmallur 

 

It seems your full code is not there.

It seems , in QA,   Number or MS/Status ( if those are fetched by g_form.getValue()) fields are not added in the form lay out.

Add it - it will work.

 

Refer: KB1698854 Fix the "Cannot read properties" error when saving an access control list (ACL) record in ... 

"Cannot read properties of null" errors

KB1649749 Unable to create ACL gives error message "onSubmit script error: TypeError: Cannot read pr... 

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: