Database view query from sys ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 10:59 PM
hello everyone,
I would like to know that I use database view in the form page, but the sys_id of database view record is not the sys_id commonly used by the system.
If I need to query data through the sys_id of database view record, What should I do, and is there an API to solve this problem?(Querying this sys_id directly with GlideRecord is invalid)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:27 PM
I read this article, but do not understand how to set up, can you give me a sample code? thank you so!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:50 PM
Hi @Wei_ Ling
var gr = new GlideAggregate('your_database_view_table');
gr.addQuery('sys_id', 'your_sys_id_value'); // Replace 'your_sys_id_value' with the actual sys_id
gr.query();
if (gr.next()) {
// Access fields as needed
var fieldValue = gr.getValue('field_name');
gs.info('Field Value: ' + fieldValue);
} else {
gs.info('No records found.');
}
-----------------------------------------------------------------------------------
Please consider marking my reply as Helpful👍 and/or Accept Solution✔️ , if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:54 PM
thank you, but it not work, the database view does not have the sys_id field.