Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

script is not working

chandanpatra
Tera Contributor

Hi All,

 

var matchFound = false;
var queueId = $sp.getParameter('location_id'); // Get current location ID
var gr = new GlideRecord('wu_location_queue');
gr.addQuery('sys_id',queueId);
gr.query();
if(gr.next())
{
var gr1= gr.name;
if (gr1.startsWith("Ben"))
{
matchFound= true
gs.addInfoMessage('test');
}
else
matchFound= false
gs.addInfoMessage('test123');

}

 

It is giving bothe alert while choosing Bengaluru location .

 

Can you help me   

1 ACCEPTED SOLUTION

Shruti
Giga Sage
var matchFound = false;
var queueId = $sp.getParameter('location_id'); // Get current location ID
var gr = new GlideRecord('wu_location_queue');
gr.addQuery('sys_id', queueId);
gr.query();
if (gr.next()) {
    var gr1 = gr.name;
    if (gr1.startsWith("Ben")) {
        matchFound = true;
        gs.addInfoMessage('test');
    } else {
        matchFound = false;
        gs.addInfoMessage('test123');

    }
}

View solution in original post

1 REPLY 1

Shruti
Giga Sage
var matchFound = false;
var queueId = $sp.getParameter('location_id'); // Get current location ID
var gr = new GlideRecord('wu_location_queue');
gr.addQuery('sys_id', queueId);
gr.query();
if (gr.next()) {
    var gr1 = gr.name;
    if (gr1.startsWith("Ben")) {
        matchFound = true;
        gs.addInfoMessage('test');
    } else {
        matchFound = false;
        gs.addInfoMessage('test123');

    }
}