Copy parent field value to child record when create new record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2018 11:38 PM
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?
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2018 09:37 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2018 03:18 AM
Hi Shashwat,
Many thanks for the response, but still i do not have any luck yet. Any other assistance would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2018 03:32 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2018 03:41 AM
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