How to add Active=true in reference qualifier if already reference qualifier exists?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 04:58 AM
Hi Team,
We are facing issue to adding active=true in reference qualifier, because we have already one reference qualifier in that field.
Scenarios is: We have three fields as reference fields on incident form. Business Services, Technical Services, and Business applications.
If we select Business services using magnifying glass, based on that Technical services and Business Applications should display when clicking on magnifying glasses on respective fields.
If we select Technical services using magnifying glass, based on that Business services and Business Applications should display when clicking on magnifying glasses on respective fields.
If we select Business Applications using magnifying glass, based on that Technical services and Business services should display when clicking on magnifying glasses on respective fields.
We have accomplished this requirement by using the following script include:
var LoadingTechServicesandBusApps = Class.create();
LoadingTechServicesandBusApps.prototype = {
initialize: function() {
},
//Loading Tech Services
loadTechServices: function() {
if(current.u_override_reference_qual == true){
var qual1 = '';
var gr = new GlideRecord('u_technical_services');
gr.query();
qual1 = 'sys_idIN';
if(gr.next()) {
qual1 += gr.sys_id.toString();
}
while(gr.next()) {
qual1 += ',' + gr.sys_id.toString();
}
return qual1;
}
else if(current.u_override_reference_qual == false){
var parentIncBS = current.u_inc_business_service;
var parentIncBA = current.u_inc_business_applications;
var qual = '';
if(parentIncBS != '') {
var childrenIncBS = new GlideRecord('cmdb_rel_ci');
childrenIncBS.addQuery('parent', parentIncBS);
childrenIncBS.addQuery('child.sys_class_name', 'u_technical_services');
childrenIncBS.query();
qual = 'sys_idIN';
if(childrenIncBS.next()) {
qual += childrenIncBS.child.toString();
}
while(childrenIncBS.next()) {
qual += ',' + childrenIncBS.child.toString();
}
return qual;
}
else if(parentIncBA != '') {
var childrenIncBA = new GlideRecord('cmdb_rel_ci');
childrenIncBA.addQuery('parent', parentIncBA);
childrenIncBA.addQuery('child.sys_class_name', 'u_technical_services');
childrenIncBA.query();
qual = 'sys_idIN';
if(childrenIncBA.next()) {
qual += childrenIncBA.child.toString();
}
while(childrenIncBA.next()) {
qual += ',' + childrenIncBA.child.toString();
}
return qual;
}
}
},
//Loading Business Applications
loadBusinessApplications: function() {
if(current.u_override_reference_qual == true){
var qual2 = '';
var gr1 = new GlideRecord('u_business_applications');
gr1.query();
qual2 = 'sys_idIN';
if(gr1.next()) {
qual2 += gr1.sys_id.toString();
}
while(gr1.next()) {
qual2 += ',' + gr1.sys_id.toString();
}
return qual2;
}
else if(current.u_override_reference_qual == false){
var parentBS = current.u_inc_business_service;
var parentTS = current.u_inc_technical_service;
var qual = '';
if(parentBS != '') {
var childrenBS = new GlideRecord('cmdb_rel_ci');
childrenBS.addQuery('parent', parentBS);
childrenBS.addQuery('child.sys_class_name', 'u_business_applications');
childrenBS.query();
qual = 'sys_idIN';
if(childrenBS.next()) {
qual += childrenBS.child.toString();
}
while(childrenBS.next()) {
qual += ',' + childrenBS.child.toString();
}
return qual;
}
else if(parentTS != '') {
var childrenTS = new GlideRecord('cmdb_rel_ci');
childrenTS.addQuery('parent', parentTS);
childrenTS.addQuery('child.sys_class_name', 'u_business_applications');
childrenTS.query();
qual = 'sys_idIN';
if(childrenTS.next()) {
qual += childrenTS.child.toString();
}
while(childrenTS.next()) {
qual += ',' + childrenTS.child.toString();
}
return qual;
}
}
},
//Loading Business Services
loadBusServices:function(){
if(current.u_override_reference_qual == true){
var qual3 = '';
var gr2 = new GlideRecord('cmdb_ci_service');
gr2.query();
qual3 = 'sys_idIN';
if(gr2.next()) {
qual3 += gr2.sys_id.toString();
}
while(gr2.next()) {
qual3 += ',' + gr2.sys_id.toString();
}
return qual3;
}
else if(current.u_override_reference_qual == false){
var parent1 = current.u_inc_technical_service;
var parent2 = current.u_inc_business_applications;
if(parent1!=''){
var children1 = new GlideRecord('cmdb_rel_ci');
children1.addQuery('parent', parent1);
children1.addQuery('child.sys_class_name', 'cmdb_ci_service');
children1.query();
qual = 'sys_idIN';
if(children1.next()) {
qual += children1.child.toString(); //gs.log("$$$456 qual1 "+qual);
}
while(children1.next()) {
qual += ',' + children1.child.toString(); //gs.log("$$$456 qual2 "+qual);
}
return qual;
}
else if(parent2!=''){
var children2 = new GlideRecord('cmdb_rel_ci');
children2.addQuery('parent', parent2);
children2.addQuery('child.sys_class_name', 'cmdb_ci_service');
children2.query();
qual = 'sys_idIN';
if(children2.next()) {
qual += children2.child.toString(); //gs.log("$$$456 qual1 "+qual);
}
while(children2.next()) {
qual += ',' + children2.child.toString(); //gs.log("$$$456 qual2 "+qual);
}
return qual;
}
}
}
};
But, another requirement is when we clicking on Business Services, we should display only Active=true records only. we are unable to find out the way for this requirement.
Please help on this and provide the possible solutions ASAP.
Thanks & Regards,
Prasanna Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2016 05:02 AM
The quickest way I can think of is to add on 'active=true^' before returning your qual on that (near to) last line of code. Something like this:
return 'active=true^' + qual;