Problem calling a non-client callable script from a client-callable script

stevehuitt
Kilo Guru

I'm in the process of refactoring our CTI processing for Istanbul per HI KB0620953 "Ensure a working CTI Integration in preparation for an Istanbul upgrade". The big change is that any inserts, updates or deletes must be performed from a non-client callable script in sys_script (business rules table) while the rest of the CTI processing is in a client callable script in sys_script. The problem I'm having is that the client callable script is getting a 'function not found' error when calling the non-client callable script. Here's the client callable script:

function cti() {

        var empNbr = sysparm_caller_id;

        var url = 'nav_to.do?uri=new_call.do';

        if (empNbr != null && empNbr != '') {

                  var user = new GlideRecord('sys_user');

                  user.addQuery('employee_number', empNbr);

                  user.query();

                  if (user.next()) {

                            // it's this statement that fails with function not found

                            var callSysId = u_CTI_Create_Call(user.sys_id, user.employee_number, user.u_lan_id);   // not client-callable per release notes

                            if (callSysId != null) {

                                      url += '?sys_id=' + callSysId; // set url to open the just created call record

                            }

                  }

        }

        answer = url; return url;

}

The u_CTI_Create_Call is defined as a non-client callable business service on the Global table and is active.

What am I doing wrong?

1 ACCEPTED SOLUTION

stevehuitt
Kilo Guru

I had opened up a HI incident on this issue and just heard back that KB0620953 as well as the comments in the OOTB CTI Processing business rule are in error - the non-client callable function that must be factored out should be a script include and not a global buisness rule (sys_script entry).


View solution in original post

21 REPLIES 21

Jochen Geist
ServiceNow Employee
ServiceNow Employee

Have you tried it with new before the script name:


var callSysId = new u_CTI_Create_Call(user.sys_id, user.employee_number, user.u_lan_id);   // not client-callable per release notes


Jochen,



Thanks for the suggestion. I hadn't tried adding new. I modified the call to include it but got the same error - 'u_CTI_Create_Call' is not defined.


stevehuitt
Kilo Guru

I had opened up a HI incident on this issue and just heard back that KB0620953 as well as the comments in the OOTB CTI Processing business rule are in error - the non-client callable function that must be factored out should be a script include and not a global buisness rule (sys_script entry).


Steve,


Did you actually get this working?


I'm doing something similar. I have my client callable script as a global business rule that calls my non-client callable script include.


The script include (in table sys_script_include) does not do the insert.       The script include is in the global scope and is not client callable.



Example:


var CTIUtils = Class.create();


CTIUtils.prototype = {


      initialize: function() {


      },



createNewCall:function(userId) {


  var nCall = new GlideRecord('new_call');


  nCall.initialize();


  nCall.caller = userId;


  nCall.insert();


  return nCall.getUniqueValue();



// I also tried this code commented out below to create a new incident, but that doesn't work either.


//var iGr = new GlideRecord('incident');


//iGr.initialize();


//iGr.caller_id = userId;


//iGr.insert();


//return iGr.getUniqueValue();



},


      type: 'CTIUtils'


};




Can you post some sample code?



Edit:   I found more info the Node File Browser


It looks like even though the script include is not-client callable, the code is still run in the SandBox


"WARNING *** WARNING *** Security restricted: User tried to run insert in GlideRecordSandbox"



Arren