- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2019 03:36 AM
Hi, I have a table form ABC and its child table form XYZ. I want to write a BR script on the parent table form that if there is a specific field value in the Parent table and there are specific field values in Child table form, the Parent Table form should not be updated.
I know we can dot walk to variables of parent table from the Child table using the keyword "Parent". Now how to dot walk to the Child table variables from the parent?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 09:21 AM
here is an example ... in a business rule on the parent:
var gr = new GlideRecord ('table_name'); //child table name
//get all children where the ref field is the sysid of the parent
gr.addQuery('child_table.ref_to_parent_field', current.sys_id);
gr.query();
while (gr.next()){
these are all the children of the record you are currently on
do what you need to do
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2019 02:25 AM
It worked, thank You!
The script I used:-
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord ('wm_task'); //child table name
//get all children where the ref field is the sysid of the parent
gr.addQuery('parent', current.sys_id);
gr.query();
while (gr.next()){
if(gr.u_hsse_fee == 0)
{
gs.addErrorMessage('The following mandatory field is not filled in the Work Order: HSSE Fees.');
current.setAbortAction('true');
}
}
})(current, previous);