How To Link Fields Between Tables

MrDevanWright
Kilo Guru

How can I have a field on 3 different tables that will mirror each other when assigned to the specific record.

 

A Table > A123 Record > The Z Field

B Table > B234 Record > The Z Field

C Table > C345 Record > The Z Field

 

In this example, record A123 would be assigned to record B234 and C345. When anyone updates The Z Field to "Pumpkin" then the other records would have their Z Field automatically updated to read "Pumpkin" as well.

2 REPLIES 2

Bert_c1
Kilo Patron

You can use a business rule, for each table. If you want more details or other options, then post how records are related (the fields on each table). There are plenty of OOB examples in your instance.

Amit Gujarathi
Giga Sage
Giga Sage

HI @MrDevanWright ,
I trust you are doing great.

 

Here's an example of how you can set up a Business Rule for Table A (A123 Record). You will need to create similar rules for Tables B and C as well, making sure to adjust the table and field references appropriately.

(function executeRule(current, previous /*null when async*/) {

    // Check if the 'Z Field' has been changed
    if (current.z_field.changes()) {
        // Update the 'Z Field' in Table B
        var grB = new GlideRecord('b_table'); // Replace 'b_table' with the actual table name
        if (grB.get('sys_id', 'B234')) { // Replace 'B234' with the actual sys_id of the record
            grB.z_field = current.z_field;
            grB.update();
        }

        // Update the 'Z Field' in Table C
        var grC = new GlideRecord('c_table'); // Replace 'c_table' with the actual table name
        if (grC.get('sys_id', 'C345')) { // Replace 'C345' with the actual sys_id of the record
            grC.z_field = current.z_field;
            grC.update();
        }
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi