- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2024 05:17 PM
Hi
I am trying to write an encoded query for the following condition - if state is closed (3) and parent sys_id matches current parent. How do I write this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 07:45 AM
😅Okay. I don't have testing environment so sorry for that I could not test the code and its output, still we will try to make it correct.
var parent = current.regulatory_task;
gs.addInfoMessage("parent = " + parent);
var totalHrs = 0;
var grRegActTsk = new GlideRecord('sn_grc_reg_change_regulatory_action_task');
// Combine conditions using ^ for AND
grRegActTsk.addEncodedQuery("state=3^regulatory_task=" + parent);
grRegActTsk.query();
while (grRegActTsk.next()) {
if (!isNaN(parseInt(grRegActTsk.u_actual_hours, 10))) {
totalHrs += parseInt(grRegActTsk.u_actual_hours, 10);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:14 AM
Thanks! I looked at the code and also had my coworker see what was missing and noticed that I was missing the '=' in the encoded query... it's always the little things. Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:19 AM
@sayalisheth You're welcome! Glad you found the issue. It's often the small details that make a big difference.😉 just kidding. Please mark my response as helpful as well ☺️
Regards,
Aniket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:11 AM
Did you check for any matched record, there is "regulatory_action_task" record with state =3 and parent. check in the list view if any single record is displaying with both condition.
As per my understanding, code is trying to get child ( task ) record referenced to current record as parent.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:15 AM
I was missing the '=' in the query... thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 08:19 AM
finally, u find it.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution