please check below script why vcac value is not taking correct one

mani55
Tera Contributor

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 

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

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

LinkedIn

based filter condition we need to pic name field of that table so value is taking correct but sys_id taking different one

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

LinkedIn

    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