Copying field values from one table to another using a reference field

mohamedalha
Tera Contributor

i have a table custome table named (special tasks) and i have another custom table named (Main Tasks) , i have linked these two by creating a referance field (special tasks) table then created a business rule that contain this code in it 

 

(function executeRule(current, previous /*null when async*/ ) {
 
    if (current.u_referance_to_a_related_list) {  
 
        var compliance = new GlideRecord('Main_Tasks');
        if (compliance.get(current.u_referance_to_a_related_list)) {
 
            current.u_explain = compliance.u_justification;
            current.u_type = compliance.u_type;
            current.u_side_type = compliance.u_subtype;
            current.u_reporting_method = compliance.u_reporting_method;
            current.u_reporting_date_issue = compliance.u_reporting_method_date;
            current.u_telegram_number = compliance.u_reportere_telegram_number;
            current.u_other_12 = compliance.u_other;
            current.issue_manager_group = compliance.u_department_groups;
            current.update();
        }
    }
 
and the outcome of the field will be like this 
 
Screenshot 2025-04-26 152436.png

 

it bring me the value itself not the value what the user has chosen, also there is a  group field that is not capturing at all , if anyone have any idea how to ahcive this please lt me know , thanks 

 

1 REPLY 1

Robert H
Mega Sage

Hello @mohamedalha ,

 

I do not understand your problem statements, but here are some things I noticed in your script:

 

new GlideRecord('Main_Tasks');

The GlideRecord parameter must be the internal table name, not the label. Please go to System Definition > Tables to find this table and its internal name. It's probably "u_main_tasks", or "{scope}.main_tasks" or something like that.

 

current.update();

Please do not use this in a Business Rule as it can lead to unexpected results.

 

Regards,

Robert