Set field value on related list(s) form same as value on form

shanerodgers
Kilo Expert

Hi, when a user creates a new form on the related list, I want the product owner to be auto filled with the same value as the product owner on the form they are creating the related form from.

This is the form where the product owner is filled from:

Pic_2.png

Here you can see the related list below it:

Pic_1.PNG

Here is the form that pops up when you click new, I want to auto fill Product Owner with the same value as PO on the main form. They are both referencing the User table.

Pic_3.png

Any help appreciated!

1 ACCEPTED SOLUTION

Hi Shane,



I've commented a few points below, hope this helps clear up a few things but let me know.



var gr = new GlideRecord('u_gbts_code_release_management');


gr.addQuery('number', current.parent);       //change number to sys_id. current.parent will return a sys_id and you need to match like for like


gr.query();


while(gr.next()) {


current.u_approver2 = gr.u_product_owners;         //product_owners implies plurality, what sort of field is this?


}


gr.update();         //you haven't changed anything on the glide record so this line is not needed.



})(current, previous);


View solution in original post

7 REPLIES 7

You could do it onLoad but you would need a Glide Ajax to get the information from the parent record.



Does the product owner change regularly? It would be preferable to have an on update business rule running on the parent to update the child records when the product owner changes (or some other viable work around), you want to keep as much of your script as possible running on the server rather than the client.


Just read your edit.



Display is perhaps preferable to onLoad but it's still processing script every time the form loads, it might seem marginal but these things have a habit of creeping up on you and before you know it you're making a cup of tea whilst waiting for your form to load. Best to have something trigger the script to change the value rather than populating it every time the form loads.


Thanks David, the product owner will not usually change after it's been set. I'll see if I can figure out how to do it like you've said.