please check below script why vcac value is not taking correct one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 10:15 PM
please check below script why vcac value is not taking correct one
//check OS
var vcac;
var query_ticket = 'cat_item=' + api_catalog.catalog_item.sys_id;
var grTicket = new GlideRecord('sc_req_item');
grTicket.addEncodedQuery(query_ticket);
grTicket.setLimit(1);
grTicket.query();
while (grTicket.next()) {
if (grTicket.cat_item.u_launch_method == "Manual") {
var gr = new GlideRecord('u_cmdb_ci_vmware_os');
gr.addEncodedQuery('u_active=true^name!=Red Hat EL 6.x English - 64 bit^u_vm_type=' + request_body.vm_type + '^u_datacenter=' + request_body.datacenter + 'u_vcac_flag=false');
gr.query();
while (gr.next()) {
vcac = gr.name;
gs.log('the value'+vcac);
}
} else {
var gm = new GlideRecord('u_cmdb_ci_vmware_os');
gm.addEncodedQuery('u_active=true^name!=Red Hat EL 6.x English - 64 bit^u_vm_type=' + request_body.vm_type + '^u_datacenter=' + request_body.datacenter + 'u_vcac_flag=true');
gm.query();
while (gm.next()) {
vcac = gm.name;
gs.log('the answer'+vcac);
}
}
}
please let me know anything worng in my script because filter is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 10:25 PM
Hi there,
What is debugging the script providing you? Up to where is the script working correct, from where is the script not working correct? And what values would you expect, what values are you actually getting?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 10:41 PM
based filter condition we need to pic name field of that table so value is taking correct but sys_id taking different one

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 10:43 PM
What is debugging the script providing you? Up to where is the script working correct, from where is the script not working correct?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2024 10:46 PM
if (grTicket.cat_item.u_launch_method == "Manual") {
above condition is working fine else part is not working and catalog item expence lines also not generated