- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2016 03:35 PM
I have a need where i need to join two tables incident(extended from task table) and new table (not an extended/reference once)
So I created a view out of these two tables.
How can i query the database view now ? Will the GlideRecord work the same way it would work for tables or do i need to use gs.sql ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 01:55 PM
You can query the database view, but you need to use the prefix before a field name. For example if you have a database view where the incident prefix is inc; then you will need to use it when you query the table:
var gr = new GlideRecord('your_database_view_table')
gr.addQuery('inc_active', true);
gr.query();
while(gr.next()){
your code here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2016 04:20 PM
You can't query Database view using GlideRecord.
If you want to join these two tables and use GlideRecord, you can use : http://wiki.servicenow.com/index.php?title=GlideRecord#addJoinQuery&gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2016 09:53 PM
Thanks Mani for answering my question. I am able to join the tables using the addJoinQuery api.
But my ultimate goal is to get an left outer join out of that ? How this can be achieved ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 01:55 PM
You can query the database view, but you need to use the prefix before a field name. For example if you have a database view where the incident prefix is inc; then you will need to use it when you query the table:
var gr = new GlideRecord('your_database_view_table')
gr.addQuery('inc_active', true);
gr.query();
while(gr.next()){
your code here
}