How to call script include in both Client Script and BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2018 01:09 AM
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());
- Labels:
-
Best Practices
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2018 01:18 AM
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 :
Regards/ Prabhash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2018 01:53 AM
Hi Prabhash.
I have done that error but still im not able to get the result
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2018 02:04 AM
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>");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2018 05:43 AM
The problem arise when parameters are read inside ajax method as, this.getParameter() which gives 'undefined' value if called from script include.