Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

I am trying to populated value from parent record to child record but while doing so I am getting value as undefined in child record. How Can I fix that?

Not applicable

This is the script that I am using to populate Vendor name from parent to child record that I am creating from related list.

    function onLoad() {
   //Type appropriate comment here, and begin script below
    var r = g_form.getReference('parent', callBack);
  
}
function callBack(r){

    g_form.setValue('u_vendor', r.number);
    g_form.setValue('u_vendor_display_name', r.u_vendor_name);
}

Number is getting populated but for Vendor name it is showing value as undefined.

1 ACCEPTED SOLUTION

Hi,

why not show those fields as dot walked field on customer record instead of creating new 2 fields to hold it

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

19 REPLIES 19

Not applicable

Hi Ankur,

For Vendor name, it displays the value for a second and then it changes to 'undefined'. It is something because of scope because these tables are created in a custom scope.

Hi,

both the tables are in same scope?

the script you created is in which scope?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Not applicable

yes, both the tables and script are in same scope.

then it should work

share the scripts screenshots and the form screenshots

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Not applicable

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

 
    current.u_vendor_display_name = current.parent.u_vendor_name;

current.u_vendor =  current.parent.number;

})(current, previous);

find_real_file.png