Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get parent case

Mi4
Tera Expert

Hi,

I want to get the yellow frame and pass the value to that case.

I have created the following BR. BR seems to be running, but the number is 0 and it seems that the query is not executed well.

Please point out.

find_real_file.png

BR

(function executeRule(current, previous /*null when async*/ ) {
var task = new GlideRecord('sn_hr_le_case');
task.addQuery('parent', current.sys_id);
task.query();
gs.info(task.getRowCount());
if (task.next()) {
if (current.reject == 'true' || current.reject == true) {
current.approval = 'rejected';
} else {
current.state = 3;
current.variables.ob_confirm_date = task.ob_confirm_date;
current.variables.last_confirm_date = task.last_confirm_date;
current.variables.boss_comment = task.boss_comment;
}
}
})(current, previous);

find_real_file.png

 

 

Thanks in advance,

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

try changing

task.addQuery('parent', current.sys_id);

to

task.addQuery('sys_id', current.parent.sys_id);

also easiest way is to use below

if (current.reject == 'true' || current.reject == true) {
current.approval = 'rejected';
} else {
current.state = 3;
current.variables.ob_confirm_date =current.parent.ob_confirm_date;
current.variables.last_confirm_date =current.parent.last_confirm_date;
current.variables.boss_comment =current.parent.boss_comment;
}

View solution in original post

2 REPLIES 2

Mike Patel
Tera Sage

try changing

task.addQuery('parent', current.sys_id);

to

task.addQuery('sys_id', current.parent.sys_id);

also easiest way is to use below

if (current.reject == 'true' || current.reject == true) {
current.approval = 'rejected';
} else {
current.state = 3;
current.variables.ob_confirm_date =current.parent.ob_confirm_date;
current.variables.last_confirm_date =current.parent.last_confirm_date;
current.variables.boss_comment =current.parent.boss_comment;
}

Hi,

Thank you for your advice.

I worked it!

 

 

Regards,