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

Hi Steve,


You have to set your non-client callable script to be accessible from All application scopes.



Arren


Hello Arren,



We have just upgraded our instance to Istanbul Patch 5 but we have totally missed to refactor the CTIProcessing script before the upgrade.


Now using this thread and also the article KB0620953, I've refactored my CTIProcessing script (global business rule) but still I get below error:



2017-07-24 14:42:21 (527) Default-thread-609 F0E38D53AD44CB40FB98954473561CEC #414543 /cti.do Parameters -------------------------


      pccstraim_id=P280847


2017-07-24 14:42:21 (527) Default-thread-609 F0E38D53AD44CB40FB98954473561CEC WARNING *** WARNING *** CTIProcessor: No client-callable function found in rhino.sandbox with name 'cti'. Make sure the containing sys_script entry is marked client-callable.



Below is the global BR:


Name: CTI Processing


Client Callable: True


Script:


function cti() {


var ctiArgs = {};


ctiArgs.cti_pxID = pccstraim_id;


var ctiEvaluator = new CTIEvaluator("new CTIUtils().goToPccstraim()", ctiArgs);


var url = ctiEvaluator.evaluate();


if(url != null ){


        answer = url;


        return url;


}else{


        url = 'navpage.do';


        return url;


}


}



Script Include: CTIUtils


Client Callable: False


Accessible from: All Application Scopes


var CTIUtils = Class.create();


CTIUtils.prototype = {


initialize: function() {


},



goToPccstraim : function(){


var url = null;


var taskID = pxID;


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


var task = new GlideRecord('task');


task.addQuery('number',taskID);


task.query();


if (task.next()){


        url = "u_qm_issues.do?sys_id="+task.sys_id;


        return url;


}


else{


        gs.addInfoMessage("Record not Found");


        url = "navpage.do";


        return url;


}


}


if (url == null) {


        gs.addInfoMessage("Record not Found");


        url = "navpage.do";


        return url;


}


},


type: 'CTIUtils'


};




Did I still miss something?


Hoping for a suggestion as I am yet to get a response from ServiceNow in the HI ticket.



Thanks in advance!



Regards,
Santhosh


My guess is that your CTI Processing Business Rule is not Active. Check that Active = true


Hello Arren,



Thank you for your response!



The CTI Processing BR is indeed Active.


Below is a screenshot FYI.


find_real_file.png



Thanks and Regards,
Santhosh


The only difference I see between your BR and mine is that mine is set to Accessible from "This application scope only"