script is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 12:53 AM
HI All,
I am receiving the current location id :var queueId = $sp.getParameter('location_id');
I need to Glide the table
var gr = new GlideRecord('wu_location_queue');
gr.addEncodedQuery('nameSTARTSWITHAmerica Walk Up Support^ORnameSTARTSWITHBengaluru Walk Up Support');
gr.query();
while(gr.next())
{
}
if the current location matches with any of the record present in the Encoded query than it should return true value else if it is should be return false.
Can anyone help me
Thanks ,
Chandan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 01:00 AM
Hello @chandanpatra
Please refer the below code:
var queueId = $sp.getParameter('location_id'); // Get current location ID
var matchFound = false; // Initialize a flag for matching result
var gr = new GlideRecord('wu_location_queue');
gr.addEncodedQuery('nameSTARTSWITHAmerica Walk Up Support^ORnameSTARTSWITHBengaluru Walk Up Support');
gr.query();
while (gr.next()) {
// Check if the current record's location ID matches the queueId
if (gr.getValue('location_id') == queueId) {
matchFound = true;
break; // Exit the loop once a match is found
}
}
// Return true if a match was found, otherwise false
gs.print(matchFound); // You can replace gs.print with a return or other handling as needed
Hope this helps!
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 01:19 AM
always going to return false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 03:12 AM
Hello @chandanpatra
- Can you please share some images.
- Check if the encoded query is set correctly.
gr.getValue('location_id')
returns the sys_id. If it is display value then use
gr.getDisplayValue('location_id') == queueId
Method 2:
- After getting the location id, modify the query by including the location field as well.
- Please share the query from table by selecting the desired location id and then we can modify the query based on user input.
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 04:42 AM
Hi @chandanpatra ,
Use below script.
var queueId = $sp.getParameter('location_id'); // Get current location ID
var answer= false; // Initialize a flag for matching result
var gr = new GlideRecord('wu_location_queue');
gr.addEncodedQuery('nameSTARTSWITHAmerica Walk Up Support^ORnameSTARTSWITHBengaluru Walk Up Support');
gr.addQuery('location_id', queueId);
gr.query();
if(gr.next())
answer= true;
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------