From 45ad8cc6fac8e1bd7fc9c0a377d1f03c2ec2486a Mon Sep 17 00:00:00 2001 From: Soumyadeep10 <78016846+Soumyadeep10@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:19:45 +0530 Subject: [PATCH 1/5] Fetch reference field value from higher-level parents in hierarchy when there is a field containing the parent record in child.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. --- ... a field containing the parent record in child.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Business Rules/Fetch reference field value from higher-level parents in hierarchy when there is a field containing the parent record in child.js diff --git a/Business Rules/Fetch reference field value from higher-level parents in hierarchy when there is a field containing the parent record in child.js b/Business Rules/Fetch reference field value from higher-level parents in hierarchy when there is a field containing the parent record in child.js new file mode 100644 index 0000000000..c76a2fba24 --- /dev/null +++ b/Business Rules/Fetch reference field value from higher-level parents in hierarchy when there is a field containing the parent record in child.js @@ -0,0 +1,12 @@ +// 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 +// I would be referring to "reference field name we want to populate" as "r1" +// I would be referring to "reference field containing parent record" as "parent" + + +(function executeRule(current, previous /*null when async*/ ) { + if (current.r1 == "" && !JSUtil.nil(current.parent.r1)) // Populate 'use-case reference field' from parent's value for the reference field' + current.r1 = current.parent.r1; + 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' + current.r1 = current.parent.parent.r1; + +})(current, previous); From ef3669929bdd007666bac6a624691164b9331195 Mon Sep 17 00:00:00 2001 From: Soumyadeep10 <78016846+Soumyadeep10@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:22:57 +0530 Subject: [PATCH 2/5] Create readMe.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 --- Business Rules/readMe.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Business Rules/readMe.js diff --git a/Business Rules/readMe.js b/Business Rules/readMe.js new file mode 100644 index 0000000000..b4a2ba66bd --- /dev/null +++ b/Business Rules/readMe.js @@ -0,0 +1,6 @@ +In this before insert/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 + +I am checking the empty value of the use-case reference field and dot walking to parents and fetching the value from them if it exists From 435913536ca89989981f118eb830c22ae3c23766 Mon Sep 17 00:00:00 2001 From: Soumyadeep Dutta <78016846+Soumyadeep10@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:38:04 +0530 Subject: [PATCH 3/5] Update and rename readMe.js to readme.md --- Business Rules/readMe.js | 6 ------ Business Rules/readme.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 Business Rules/readMe.js create mode 100644 Business Rules/readme.md diff --git a/Business Rules/readMe.js b/Business Rules/readMe.js deleted file mode 100644 index b4a2ba66bd..0000000000 --- a/Business Rules/readMe.js +++ /dev/null @@ -1,6 +0,0 @@ -In this before insert/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 - -I am checking the empty value of the use-case reference field and dot walking to parents and fetching the value from them if it exists diff --git a/Business Rules/readme.md b/Business Rules/readme.md new file mode 100644 index 0000000000..24601f2afa --- /dev/null +++ b/Business Rules/readme.md @@ -0,0 +1,12 @@ +This is a "**before insert/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 + +In the code, we are referring to "reference field name we want to populate" as "_r1_" +In the code, we are referring to "reference field containing parent record" as "_parent_" + +The "**JSUtil.nil**" is being used to check for empty/null value for the field. + + +Through the code we are checking the empty value of the use-case reference field and dot walking to parents and fetching the value from them if it exists From dbc06a651ecc822230b1ccc68349dfc1e587f62a Mon Sep 17 00:00:00 2001 From: Soumyadeep Dutta <78016846+Soumyadeep10@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:39:05 +0530 Subject: [PATCH 4/5] Create Fetching reference field value from higher-order parents --- .../Fetching refrence field value from higher-order parents | 1 + 1 file changed, 1 insertion(+) create mode 100644 Business Rules/Fetching refrence field value from higher-order parents diff --git a/Business Rules/Fetching refrence field value from higher-order parents b/Business Rules/Fetching refrence field value from higher-order parents new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Business Rules/Fetching refrence field value from higher-order parents @@ -0,0 +1 @@ + From 75a7f58f5a74d85b1576448315556d91b2adbd27 Mon Sep 17 00:00:00 2001 From: Soumyadeep Dutta <78016846+Soumyadeep10@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:45:19 +0530 Subject: [PATCH 5/5] Delete Business Rules/Fetching refrence field value from higher-order parents --- .../Fetching refrence field value from higher-order parents | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Business Rules/Fetching refrence field value from higher-order parents diff --git a/Business Rules/Fetching refrence field value from higher-order parents b/Business Rules/Fetching refrence field value from higher-order parents deleted file mode 100644 index 8b13789179..0000000000 --- a/Business Rules/Fetching refrence field value from higher-order parents +++ /dev/null @@ -1 +0,0 @@ -