Auto populate reference field value on new form for another table from related list new button

Pravin11
Tera Contributor

Hi Team,

 

Can someone help me with the requirement where : 

 

I have created a relation between two tables both are extended from task, if I am creating a new record from related list New button the field should auto populate.

1 REPLY 1

anand-bhosle
Tera Guru

@Pravin11 Which field should auto-populate? Parent info on child table record?

 

  1. The built-in behavior in ServiceNow let you populate the info on child record if you have that reference properly.
  2. Or You can create an OnLoad Client script on child table which Parses the URL for the sysparm that the related-list “New” button sends

var val = g_form.getParameter('sysparm_' + myRefField);
if (!val) {
var a = g_form.getParameter('sysparm_query') || '';
var b = q.match(new RegExp(myRefField + '=([^&]+)'));
val = b && b[1];
}

if (val)
g_form.setValue(myRefField, val);

 

If that helps, please mark my answer helpful 

 

Thanks