- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2023 10:07 PM
Hello Experts,
I have two tables :
1: "sys_atf_test" where I have field called "Name" string type.
2: "tm_test_case" where I have field called "ATF Test Name" string type.
I want to check if there is any common values in both table fields through script ,Also I want to print the value which is common in both table fields. Any help ?Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2023 05:13 AM
@Prashant Kumar6 Try with following.
var glideATFTest = new GlideRecord('sys_atf_test');
glideATFTest.query();
while(glideATFTest.next){
var glideTestCase = new GlideRecord('tm_test_case');
glideTestCase.addEncodedQuery('u_atf_test_nameLIKE'+glideATFTest.getDisplayValue('name'));
glideTestCase.query();
if(glideTestCase.next()){
gs.info('Found a duplicate name '+glideTestCase.getValue('u_atf_test_name'));
}
}
Also, in order to find the correct query, I recommend you to do a manual search on u_atf_test_name field on list view of sys_atf_test table, copy the encoded query and use the same here in this script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2023 10:26 PM
@Prashant Kumar6 You can use the following script to check the common names.
var glideATFTest = new GlideRecord('sys_atf_test');
glideATFTest.query();
while(glideATFTest.next){
var glideTestCase = new GlideRecord('tm_test_case');
glideTestCase.addQuery('atf_test_name',glideATFTest.getValue('name'));//Replace atf_test_name with your field name in tm_test_case
glideTestCase.query();
if(glideTestCase.next()){
gs.info('Found a duplicate name '+glideTestCase.getValue('atf_test_name'));//Replace atf_test_name with your field name in tm_test_case
}
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2023 10:42 PM
Thanks @Sandeep Rajput : Let me check and will get back to you .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2023 04:04 AM
Hi @Sandeep Rajput : I tried and I am getting desired output as I know there are some duplicate records but it is not finding that :

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2023 05:13 AM
@Prashant Kumar6 Try with following.
var glideATFTest = new GlideRecord('sys_atf_test');
glideATFTest.query();
while(glideATFTest.next){
var glideTestCase = new GlideRecord('tm_test_case');
glideTestCase.addEncodedQuery('u_atf_test_nameLIKE'+glideATFTest.getDisplayValue('name'));
glideTestCase.query();
if(glideTestCase.next()){
gs.info('Found a duplicate name '+glideTestCase.getValue('u_atf_test_name'));
}
}
Also, in order to find the correct query, I recommend you to do a manual search on u_atf_test_name field on list view of sys_atf_test table, copy the encoded query and use the same here in this script.