Have to set field value from parent to child table field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 08:23 AM
Hello All/
I have a field on parent case table is "Effective date", we want to set same field value on child task table "Effective From".
After insert/update on task table, but is not set on child table field. Could you please guide ?
(function executeRule(current, previous /*null when async*/) {
// gs.info("current parent :" +current.parent);
// current.u_effective_from = current.parent.variables.u_effective_date;
var ga = new GlideRecord("sn_hr_core_task");
ga.addQuery('sys_id',current.parent);
ga.query();
if(ga.next()){
//current.u_effective_from = current.u_effective_date;
current.u_effective_from = current.parent.variables.u_effective_date;
current.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 10:18 AM
Hello Mohith,
HR task table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 10:45 AM
Just replace your effective date field name in below script
var gr= new GlideRecord('sn_hr_core_task');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.your_effective_field_back_end_name=current.parent.u_effective_date;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2022 10:19 PM
Hi,
you would require before insert BR on child HR task table sn_hr_core_task
This would work during insertion
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.u_effective_from = current.parent.u_effective_date;
})(current, previous);
If you want the Child date to change based on parent variable/field change then you can use after update BR on HR Case table and query Child table and update it
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 02:41 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader