Skip to content

Commit b2698d3

Browse files
authored
Fetching reference field value from higher-level parents.js
In this before insert or update Business Rule, we are fetching a reference field value from higher-level parents in hierarchy when there is a field containing the parent record in the children and our use-case reference field is present in all the tables in hierarchy.
1 parent aa384d5 commit b2698d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// In this before insert or update Business Rule, we are fetching a reference field value from higher-level parents in hierarchy when there is a field containing the parent record in the children and our use-case reference field is present in all the tables in hierarchy
2+
// I would be referring to "reference field name we want to populate" as "r1"
3+
// I would be referring to "reference field containing parent record" as "parent"
4+
5+
6+
(function executeRule(current, previous /*null when async*/ ) {
7+
if (current.r1 == "" && !JSUtil.nil(current.parent.r1)) // Populate 'use-case reference field' from parent's value for the reference field'
8+
current.r1 = current.parent.r1;
9+
else if (current.< reference field name we want to populate > == "" && !JSUtil.nil(current.parent.parent.r1)) // Populate 'use-case reference field' from 'parent of parent'
10+
current.r1 = current.parent.parent.r1;
11+
12+
})(current, previous);

0 commit comments

Comments
 (0)