How to call script include in both Client Script and BR

Rameshnathan
Tera Expert

Hi I want to call one Script Include in Both Client Script and Business Rule (I have Checked the Client Callable Check box in Script Include)

Script Include:

var getGroupName = Class.create();

getGroupName.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getDetails: function(){

var asgment = [];

var priority = [];

var rest = this.getParameter('sysparm_ServiceReqType');

var comp =   this.getParameter('sysparm_company');

var grp = new GlideRecord('x_mapping_table');

grp.addQuery('request', rest);

var cmp = grp.addQuery('company',comp);

cmp.addOrCondition('company',"");

var order = grp.orderByDesc('company');

order.addOrCondition('request');

grp.query();

if(grp.next()){

var myAnswer = {

"assignment_group" : grp.getValue('assignment_group'),

"priority" : grp.getValue('priority')

};

var result = JSON.stringify(myAnswer);

return result;

}

},

type: 'getGroupName'

});

Calling Script Include in BR:

I have written this below code in BR for calling the Script include but its showing error

var gn = new getGroupName();

      gs.info("Call Script include" + gn.getDetails());

6 REPLIES 6

prabhash_snow
Mega Expert

Hi Ramesh,



As per your code, the Script Include Name is   getGroupName, But you are trying to crating the object incorrectly



"var gn = new getGroupName1();"   // getGrouoName1 is not defined.



try correcting this error. For Calling a Script Include Client side, use GlideAjaxAPI.



Reference :



https://docs.servicenow.com/bundle/istanbul-application-development/page/app-store/dev_portal/API_re...



Regards/ Prabhash


Hi Prabhash.



I have done that error but still im not able to get the result



Thanks


Rajesh T
Giga Expert

Call Script Include   from Server Side.



gs.include("getGroupName ");


var groupName= new getGroupName ();


groupName.getDetails();



Call Script Include from Client Side:



var ga= new GlideAjax("<exaxt name of sctipt include name>");


Veera
ServiceNow Employee
ServiceNow Employee

The problem arise when parameters are read inside ajax method as, this.getParameter() which gives 'undefined' value if called from script include.