- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 09:56 AM - edited 01-24-2023 10:01 AM
Client script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var arr;
var parentRec = g_form.getValue('u_service_business_app');
var ga = new GlideAjax('bappUtils');
ga.addParam('sysparm_name', 'getChildValues');
ga.addParam('sysparm_recparent', parentRec);
ga.getXML(myCallBack);
function myCallBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// arr = 'sys_idIN' + answer; //.split(",");
var splitAnswer = answer.split(',');
for (var i = 0; i < splitAnswer.length; i++) {
g_form.setValue('u_tech_serv_off_app_service', splitAnswer[i]); //g_form.getValue('description') + '\n' + splitAnswer[i]);
}
// g_form.setValue('u_tech_serv_off_app_service', arr);
}
}
Script Include :
var bappUtils = Class.create();
bappUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChildValues: function() {
var array = [];
var uid = this.getParameter('sysparm_recparent');
var prj = new GlideRecord('cmdb_rel_ci');
prj.addEncodedQuery("parent.sys_class_name=cmdb_ci_business_app^child.sys_class_name=cmdb_ci_service_auto");
prj.addQuery('parent.sys_id', uid);
prj.query();
while (prj.next()) {
var list1 = prj.child.sys_id;
array.push(list1); JSON.stringify(variable);
}
return JSON.stringify(array); //'sys_idIN' + array; //.toString(); //return 'sys_idIN' + retArrayy;
},
type: 'bappUtils'
});
#Anyone help me out here
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 03:53 AM
like this
getChildValues: function(u_service_business_app) {
var array = [];
var prj = new GlideRecord('cmdb_rel_ci');
prj.addEncodedQuery("parent.sys_class_name=cmdb_ci_business_app^child.sys_class_name=cmdb_ci_service_auto");
prj.addQuery('parent.sys_id', u_service_business_app);
prj.query();
while (prj.next()) {
var list1 = prj.child.sys_id;
array.push(list1.toString());
}
return 'sys_idIN' + array;
},
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 03:53 AM
like this
getChildValues: function(u_service_business_app) {
var array = [];
var prj = new GlideRecord('cmdb_rel_ci');
prj.addEncodedQuery("parent.sys_class_name=cmdb_ci_business_app^child.sys_class_name=cmdb_ci_service_auto");
prj.addQuery('parent.sys_id', u_service_business_app);
prj.query();
while (prj.next()) {
var list1 = prj.child.sys_id;
array.push(list1.toString());
}
return 'sys_idIN' + array;
},
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 04:11 AM
Hello Ankur, it's not showing any values in application service field i gave condition like this
javascript:'parent='+current.u_service_business_app;
condition is finde or need to try any different appraoch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 04:22 AM
are you sure the table has field with correct name i.e. parent
also that field should refer to table being referred by u_service_business_app
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 04:53 AM
No parent field is not and it's not referring that table, business application and application services are both different tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2023 04:54 AM - edited 01-25-2023 04:55 AM
Reference qualifier condition: Javascript application services backend name i need to mentioned or i need to call the function itself here only orn Anything else?