Compare list of records to another list to find matches

Dazler
Mega Sage

Hi,

 

I have created a custom table for our Role Base Access.  This table contains what access to grant a user based on their job roles.  The current project that I am working on involves job changes, where a user joins another position within the company.  

 

The goal is to use the custom table to retrieve what access they were granted based on their previous job role.  Then retrieve the access they should be granted for their new role.  Now that we have both list, I need do the following:

 

1. compare both list and find a match based on 2 fields on the table.

2. A list of the items in the previous job role, that didn't match.

3. A list for the items in the new job role, that didn't match.

 

Does anyone know how I can accomplish this?

1 ACCEPTED SOLUTION

jaheerhattiwale
Mega Sage
Mega Sage

@Dazler Use below script:

 

var firstTable = new GlideRecord("FIRST TABLE");
firstTable.query();

while(firstTable.next()){
    var scondTable = new GlideRecord("SECOND TABLE");
    scondTable.addQuery("SECOND TABLE FIELD", "VALUE FROM FIRST TABLE FIELD");
    //Add the queries here if needed
    scondTable.query();

    if(scondTable.hasNext()){
        //Match found
    }else{
        //Match not found
    }
}
 
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

6 REPLIES 6

reshmapatil
Tera Guru

Hi @Dazler ,

 

Check below documentation link to create filters and breadcrumbs by using the script:

 

https://docs.servicenow.com/bundle/tokyo-platform-administration/page/administer/list-administration...

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

Hi @reshmapatil 

 

I am unsure how this help me in finding my answer.  What I am doing in Flow designer.