- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 11:52 PM
Hi all,
my third party is providing me the list of application services and its blackout values in the below format
var reqData = {
"ID": "8611",
"Details": "INPAT:SBBW_Monday_14:16_R0",
"Recurrence": "Monthly",
"StartTime": "06/05/2024 14:00:06",
"EndTime": "06/05/2024 16:00:16",
"MType": "Day of the month",
"Application": [{
"AppName": "DI_metal_app_service"
},
{
"AppName": "DI_metal_app_service1"
},
{
"AppName": "DI_metal_app_service2"
}
]
}
how to populate the application services name in the below format in the blackout schedule
I have tried the below code but it does not help me
var conditiona = "";
var gr = new GlideRecord('cmn_schedule_blackout');
gr.addQuery('sys_id', 'e518327987b9829c49aa0d030cbb350c');
gr.query();
if (gr.next()) {
gs.info('dsssdggg:,.........................' + gr.source);
var arrayUtil = new global.ArrayUtil();
for (var i = 0; i < reqData.Application.length; i++) {
var appName = reqData.Application[i].AppName;
gs.info('appName..........' + appName);
if (conditiona) {
conditiona += "OR";
}
conditiona += '("ref_cmdb_ci_service_auto.name="' + appName + ' ")' ;
}
}
gr.condition = "(" +conditiona + ")";
gr.update();
please provide me a solution if possible.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:45 AM
By using the "IN" operator you're able to execute a much more efficient query. OR conditions in SQL are much slower and impact instance performance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:04 AM
Hi @mouli7 ,
You can set the value of this condition field via script by passing the encoded quety in the script.
Create a same filter in the list view copy the encoded query and pass and set value in script.
I hope this helps
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:30 AM
i am not sure how to do that via scripting
can you please try and share me the code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 12:41 AM
I'd recommend looking up the CI's (assuming those are the full names) to improve efficiency when the Maintenance Window & Conflict Checker business rules run.
(function(){
var reqData = {
"ID": "8611",
"Details": "INPAT:SBBW_Monday_14:16_R0",
"Recurrence": "Monthly",
"StartTime": "06/05/2024 14:00:06",
"EndTime": "06/05/2024 16:00:16",
"MType": "Day of the month",
"Application": [{
"AppName": "DI_metal_app_service"
},
{
"AppName": "DI_metal_app_service1"
},
{
"AppName": "DI_metal_app_service2"
}
]
};
if (!reqData || !reqData.hasOwnProperty('Application') || !Array.isArray(reqData.Application))
return;
var applicationCMDBSysIds = [];
reqData.Application.forEach(function(application){
var cmdbCI = new GlideRecord('cmdb_ci_service_auto');
cmdbCI.setLimit(1);
cmdbCI.addQuery('name' , application.AppName);
cmdbCI.query();
if(cmdbCI.next()){
applicationCMDBSysIds.push(cmdbCI.getUniqueValue())
} else {
gs.warn(gs.getMessage("Unable to find Application with name {0} for Maintenance Schedule",[application.AppName] ));
}
});
if(applicationCMDBSysIds.length == 0)
return;
var scheduleGR = new GlideRecord('cmn_schedule_blackout');
if(scheduleGR.get('e518327987b9829c49aa0d030cbb350c')){
scheduleGR.setValue('condition' , 'sys_idIN' + applicationCMDBSysIds.join(','));
scheduleGR.update();
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 01:21 AM
it is working
But can you please send me how to do the same in OR condtion format to map the sysyids
this can also help me.