How To Script the Condition field on table

dhanashree2011
Tera Contributor

Hi All,

 

Thanks in Advance.

I have a requirement where i have to match condition type field from one table to condition type field in another table.

I need to know how we can Script the Condition type field( like glide record and Query).

dhanashree2011_0-1731431889082.png

 

dhanashree2011_2-1731431962759.png

 

 

 

1 REPLY 1

EricS_
Kilo Contributor

Here's how you can accomplish this using GlideRecord and GlideFilter :

  1. Retrieve records from both tables: You will first retrieve records from the first table and then use this information to query the second table.
  2. Using GlideFilter to evaluate conditionsThe condition type field usually contains an encoded string (like an encoded query). You can use 

 

GlideFilter.checkRecord()

 to compare this condition with the current record.

 

 

Script examples:

 

// Retrieve records from first table
var tableA = new GlideRecord('table_a');
tableA.query();

while (tableA.next()) {
    // Retrieve records from second table
    var tableB = new GlideRecord('table_b');
    tableB.query();

    while (tableB.next()) {
        // Compare the condition field between the two tables
        var match = GlideFilter.checkRecord(tableB, tableA.u_condition_field);
        
        if (match) {
            // If the condition is satisfied, perform an action
            gs.info('Condition matched for record: ' + tableB.getDisplayValue());
        }
    }
}

 

 

 

Explanation :

 

GlideRecord('table_a')

 : Query the first table.

GlideFilter.checkRecord(tableB, tableA.u_condition_field)

 : Checks if the current record in satisfies the condition defined in .tableBtableA.u_condition_field

 

Recommendation :

To make writing complex queries a breeze, use this method to format your condition fields as encoded strings. This will streamline evaluating conditions between the two tables! If you have any questions or need help, I’m here for you!

 

Have an amazing day,  

Eric