GlideRecord script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 11:10 AM - edited 12-14-2023 11:11 AM
Hi,
how to write Glide Record Query to get sysid of service_offering using assignment_group sysid in service offering table.
I am using this query.
var gr = newGlideRecord('service_offering');
gr.addQuery('assignment_group', agsysid);
gr.setLimit(1);
gr.query();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 11:15 AM - edited 12-14-2023 11:24 AM
I dont see any issue with the script. Just need to use next to get the record. If you are not getting the result, make sure you are using the right field of service offering. There is also a Approval Group and Support Group and has different field name. May need to replace the addQuery with the right field name.
var so_sys_id = '';
var gr = newGlideRecord('service_offering');
gr.addQuery('assignment_group', agsysid);
gr.setLimit(1);
gr.query();
if (gr.next())
so_sys_id = gr.sys_id;
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 11:16 AM
Hi @akshay_sharma26 ,
Try this
var gr = newGlideRecord('service_offering');
gr.addQuery('assignment_group', agsysid);
gr.setLimit(1);
gr.query();
if(fr.next()){
var id = gr.sys_id;
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 11:49 AM
What are you trying to do exactly? And from where (Business Rule, Flow, Workflow, etc...)? Reason I ask is your example script is filtering on the "Change group [assignment_group]" field AND you just want 1 record returned (setLimit) BUT a group can be assigned to MANY records, so it's hard to tell what record you will get back.
Another issue is your "agsysid" JavaScript variable is defined so not where that is or coming from. And as others have mentioned, you need to use "next" to get to the record.