- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 08:31 AM
Is inc.query(); is necessary to execute a script
or can we use any alternatives instead of inc.query();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 06:33 PM
Hello @Veena18 ,
To fetch single record from any table using GlideRecord and using one field value(ex:sys_id) on record with we can go with rec.get(sys_id) and no need to use rec.query().
To get Multiple records for all the addQuery's in the script of GlideRecord needs .query() to fetch the records from the table.
If my response is useful, then kindly mark it as "Accept as Solution" and " Helpful."
This helps community and as well as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 06:48 PM
without query() function the GlideRecord won't query the table and you won't be able to iterate the result
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 09:23 PM
@Veena18
query() function in ServiceNow's GlideRecord API is used to retrieve records from tables in the ServiceNow database. It executes the query.
Refer:https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_script...
https://docs.servicenow.com/bundle/vancouver-api-reference/page/script/server-scripting/concept/c_Us...
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
‎02-04-2024 09:42 AM
Hi @Veena18,
Query(Example: br.query or inc.query) is a mandatory method while working with GlideRecords.
If my response is useful, then kindly mark it as "Accept as Solution" and " Helpful."
This helps community and as well as me.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 06:33 PM
Hello @Veena18 ,
To fetch single record from any table using GlideRecord and using one field value(ex:sys_id) on record with we can go with rec.get(sys_id) and no need to use rec.query().
To get Multiple records for all the addQuery's in the script of GlideRecord needs .query() to fetch the records from the table.
If my response is useful, then kindly mark it as "Accept as Solution" and " Helpful."
This helps community and as well as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 06:48 PM
without query() function the GlideRecord won't query the table and you won't be able to iterate the result
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 09:23 PM
@Veena18
query() function in ServiceNow's GlideRecord API is used to retrieve records from tables in the ServiceNow database. It executes the query.
Refer:https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_script...
https://docs.servicenow.com/bundle/vancouver-api-reference/page/script/server-scripting/concept/c_Us...
Please mark this response as correct or helpful if it assisted you with your question.