How to copy fields value from Parent to Child form?

Erica2
Tera Contributor

Hello everyone,

My use case is in my parent form, I have meeting start and end date fields where the end user select the dates. 

I also have the same fields in my child form.  How do I copy the start and end date from the parent to child form when the record is insert or update so that those dates will show up in the child form as well?

Thanks

 

1 ACCEPTED SOLUTION

try this is scripts background.

var gr = new GlideRecord('x_531698_bod_syst_director_requests'); 
gr.addQuery('sys_id', 'sysid'); //repleace sysid with a sysid from one of your parent records.
gr.query();
if (gr.next()){
   gs.info(gr.number);
}

View solution in original post

19 REPLIES 19

I would do a before insert/update BR on the child table. This is making some assumption like that they field names are.

var gr = new GlideRecod('parent table');
gr.addQuery('sys_id', current.parent);//you will need to repace parent with the correct field name if parent is not the field on the child record.
gr.query();
if (gr.next()){
   current.start_date = gr.start_date.getDisplayValue();
   current.end_date = gr.end_date.getDisplayValue();
}

Erica2
Tera Contributor

Hi @Brian Lancaster 

The parent is the field on the child. I don't where I did wrong, but the BR did not trigger. 

find_real_file.png

 

 I create BR on the Child Table. Here is my entire code, could you please take a look?  Thank you

find_real_file.png

 

find_real_file.png

On the child table do you have a reference field to the parent table? It may not be called parent. For example on the sc_task table the reference field to the parent is called request_item. Also since this is a before business rule you should not current.update() as it is not needed and cause other BRs to trigger again.

@Brian Lancaster 

I looked the parent field in the child table and it is current point to task table.  Do I need to create a new field called parent_value and reference it to the parent table?

Currently the Parent and the child is extended to task table.

 

find_real_file.png

If you add parent to the list layout does it have the correct info in it. AKA the correct number and if you click on it does it take you to the parent?