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-29-2018 11:43 PM
Hello,
Just write a Display Business Rule on your Related List Time Worked Table as per the script mentioned below:
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
displayData();
function displayData(){
if(current.isNewRecord()){
if(current.parent.field_name){
current.u_primary_task = current.parent.number;
}
}
}
})(current, previous);
In the above script, Replace "parent" id required with the field name on your related list table which is referring to your Incident Table. For me it was "parent".
Hope this help. Please mark the answer as helpful/correct based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2018 02:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2018 07:26 AM
Even if you can have a custom ui action for that related list instead of that new button if you can use a seperate new button you can even pass the parameters in the URL and you can parse the URL and set the field values on load of the form .let me know if you have any queries on this kind of approach
Hope that helps
Thanks,
Siva
Mark this response as correct if that really helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2018 09:29 AM
Hi
1) Got the form layout of "Time Worked" table by right click on the header.
2) Select the field "Task" field and click on "tree icon" then select the field that you want to show on the form.
For example :
Hope this will work.
Thanks,
Kanchan