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 08:40 AM
Hello,
Is "sn_hr_core_task" the parent table if yes then use the below script:-
(function executeRule(current, previous /*null when async*/) {
var ga = new GlideRecord("sn_hr_core_task");
ga.addQuery('sys_id',current.parent);
ga.query();
if(ga.next()){
current.u_effective_from = ga.u_effective_date;
current.update();
}
})(current, previous);
Please mark answer correct/helpful based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 08:44 AM
hello
If your business rule is on HR task table you need to glide record case table in order to get the date value like below
note : Use variables.u_effective_date if thats a variable from variable editor or if it is from the form then you can use the below script
(function executeRule(current, previous /*null when async*/) {
var ga = new GlideRecord("sn_hr_core_case");
ga.addQuery('sys_id',current.parent);
ga.query();
if(ga.next()){
var gr= new GlideRecord('sn_hr_core_task');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_effective_from =ga.u_effective_date;
gr.update();
}
}
})(current, previous);
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 09:19 AM
Hello
In parent table date is there , but "Effective Form" is not set any value from parent table.
"Effective Form" field is custom view field of task table.
could you please update ?
BR is running on After insert/ update on task table .
var ga = new GlideRecord("sn_hr_core_case");
ga.addQuery('sys_id',current.parent);
ga.query();
if(ga.next()){
var gr= new GlideRecord('sn_hr_core_task');
gr.addQuery('sys_id',current.sys_id);
gr.query();
if(gr.next())
{
gr.u_effective_from =ga.u_effective_date;
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2022 10:02 AM
if your BR is on HR task table
try with this 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();
}