Getting data from two different tables
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 04:14 AM
Hi Community,
- I have a situation where I have 2 tables (Table A and Table B).
- Both tables have Name as common field
- Table A has fields : Name, number, expiry, etc.
- Table B has fields : Name, Application name.
- I want to get the application name from Table B based on the matching of both the Name fields from Table A and B and use that Application name in submitting a catalog request. (This has to be done for all records in Table A)
2 REPLIES 2
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 04:39 AM
Hi @Aswanth Suraj ,
Please refer below script
var gr = new GlideRecord('tableA'); // Give the backend name of table A
gr.addQuery('active', true);
gr.query();
if (gr.next()) {
var applicationNameArr= [];
var grB = new GlideRecord('tableB');// Give the backend name of Table B
grB.addQuery('gr.name', 'TableB_Name'); // Pass the common name value in table A&B
grB.query();
while(grB.next()){
applicationNameArr.push(grB.application_name.toString()); // Give the backend name of application_name
}
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2024 04:45 AM
Thanks for the reply.
But could you tell me where should I use this script and
How to bring the application name here. Can you please help?