Please help me with the BR where I need to populate the value from a list type field to related list

swaschak
Tera Contributor

I am having a field ABC in a form where the field type is list and referring to table MNC. In the same form I have related list as "Relations" where it is referring to the same ABC table. I want the values provided in ABC field should populate the same in Relations. it would be whenever there is an update in the field value it will reflect the same in the below related list. 
I want this to be done by a after update BR. Can anyone help me with the script.

2 REPLIES 2

Harish Bainsla
Tera Sage
Tera Sage

hi please check below code

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

var newABCValue = current.ABC;

var rel= new GlideRecord('MNC');
rel.addQuery('ABC', newABCValue);
rel.query();

while (rel.next()) {

rel.ABC = newABCValue;
rel.update();
}
})(current, previous);

swaschak
Tera Contributor

This will not work in case I am having multiple record in the field ABC (as this is a list type of field). Can you suggest this code using array ?