Copy parent field value to child record when create new record

attanhes
Tera Guru

Hi,

I have added task extended table (task_time_worked) to incident form through related list. I wanted to populate some fields value from parent record to child record (Incident==>Time worked) when user click on new record.

This question has been asked few times in community, unfortunately i could not make my business rule working.

Can someone please help me with this?

find_real_file.png

I have created a before business rule with below code. Unfortunately it doesn't work. Please help me

var gr = new GlideRecord('incident');
gr.addQuery('number', current.sys_id);
gr.query();
if(gr.next())
   {
   current.u_primary_task = gr.number;
       
   }

 

 

 

 

 

8 REPLIES 8

Shashwat  Saxen
Giga Expert

var gr = new GlideRecord('incident');
gr.addQuery('number', current.sys_id);
gr.query();
if(gr.next())
{
current.u_primary_task = gr.getValue('number');    //gr.number will give null value 
}

Hi Shashwat,

Many thanks for the response, but still i do not have any luck yet. Any other assistance would be greatly appreciated.

Alikutty A
Tera Sage

Hello,

I could see you already have a reference to incident as the time worked is created from the incident list. What value are you trying to populate?

You can add a before insert BR on task_time_worked table with below script

current.u_primary_task = current.task;

Anurag Tripathi
Mega Patron
Mega Patron

Just have this in your BR

 

current.u_primary_task = gr.task;

 

Question: When you already have the Task field there that already has incident number, why do you want to populate the same info on primary task field?

 

Please mark this answer correct if you find my answer correct/helpul.

-Anurag

-Anurag