How to update the form field value based on the related list record field value.

Munna1
Tera Contributor

My requirement is to update the (Environment field value) dropdown field, based on the value in the Key Values related list on the same form. I am trying with Business rule After update, but it is not working out.

 

I have written after insert and update BR on related list table (child table) but it is not working.

condition : key is environment and value is development.

 

var gar = new GlideRecord('cmdb_ci_cloud_db'); // parent table
    gar.addQuery('sys_id',current.name);
    gar.query();
    if(gar.next())
{
        gar.environment= 'Development';
        gar.update();
    }
 

Can any one have any  better idea ?

Thanks,

 

1 ACCEPTED SOLUTION

HI @Munna1 

Yes Please check the table name as Abhnezer Mentioned 

Add Conditions in the BR to trigger only when key value is specific or you can add that check in the code too.

var gar = new GlideRecord('cmdb_ci_cloud_db_cluster'); // parent table
gar.addQuery('sys_id', current.configuration_item);
gar.query();
if (gar.next()) {
    if (current.value == 'y')
        gar.environment = 'Development'; //use development choice backend value here.
    else if (current.value == 'z')
        gar.environment = 'acceptance'; //use acceptance choice backend value here.
    gar.update();
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

5 REPLIES 5

is the BR working correctly now ? if its I would appreciate it if you mark the answer helpful