Field was not populating after using scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 09:47 PM
We have requirement like,
Condition: life cycle status = operational, category = physical, Discovery source = manual entry or servicenow, warranty expiration >= beginning of today , os in WINDOWS SERVER 2016,WINDOWS SERVER 2016 DATACENTER,WINDOWS SERVER 2016 R2,
output : if above conditions are all met, then Ci supportability as yes otherwise No
We have used scheduled job and added some conditions.
Script:
var OG = new GlideRecord('cmdb_ci_win_server');
OG.addEncodedQuery("install_status=4^osINWINDOWS SERVER 2016,WINDOWS SERVER 2016 DATACENTER,WINDOWS SERVER 2016 R2,WINDOWS SERVER 2016 STD,WINDOWS SERVER 2019,Windows 2019, WINDOWS SERVER 2016 STD, WINDOWS SERVER 2019, Standard^warranty_expiration>=javascript:gs.beginningOfToday()^category=Physical^discovery_sourceINManual Entry,ServiceNow");
OG.query();
while (OG.next()) {
if (OG.install_status == 4 && OG.warranty_expiration >= gs.beginningOfToday() && OG.category == "Physical" && (OG.discovery_source == 'Manual Entry' || OG.discovery_source == 'ServiceNow') && (OG.os == 'WINDOWS SERVER 2016' ||
OG.os == 'WINDOWS SERVER 2016 DATACENTER' ||
OG.os == 'WINDOWS SERVER 2016 R2' ||
OG.os == 'WINDOWS SERVER 2016 STD' ||
OG.os == 'WINDOWS SERVER 2019'|)) {
OG.u_ci_supportability = "Yes";
OG.update();
} else {
OG.u_ci_supportability = "No";
OG.update();
}
}
After executing the code , the Ci supportability changed to yes , but the No conditions is not working.
Please help me on this issue.
Thanks in advance.
Sukanya. K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 10:28 PM
Hi @sukanya kotni ,
can you try
var OG = new GlideRecord('cmdb_ci_win_server');
OG.addEncodedQuery("install_status=4^warranty_expiration>=javascript:gs.beginningOfToday()^category=Physical");
OG.query();
while (OG.next()) {
// Check if the record meets the "Yes" conditions
if ((OG.os == 'WINDOWS SERVER 2016' ||
OG.os == 'WINDOWS SERVER 2016 DATACENTER' ||
OG.os == 'WINDOWS SERVER 2016 R2' ||
OG.os == 'WINDOWS SERVER 2016 STD' ||
OG.os == 'WINDOWS SERVER 2019' ||
OG.os == 'Windows 2019' ||
OG.os == 'WINDOWS SERVER 2019 Standard') &&
(OG.discovery_source == 'Manual Entry' || OG.discovery_source == 'ServiceNow')) {
OG.u_ci_supportability = "Yes";
} else {
OG.u_ci_supportability = "No";
}
OG.update(); // Save the changes
}
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 02:01 AM
Hi @Bhavya11 ,
Thank you for the response.
We have tried the above code and run the job. Some CI's supportability got changed as NO, remaining CIs still empty.
Please help me on this.
Thanks,
Sukanya. K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 02:05 AM
Hi,
You may opt to utilize the decision builder to create a decision table rather than writing a scheduled job. This approach is more straightforward and facilitates complete configuration. However, it is advisable to incorporate it into a simple flow.
Suresh.