In Zoho Creator, I've got two form that needs to be linked together.
Form A: Is a reward counter, where certain questions are awarded certain points, and is stored per entry, in a column called "Points_Earned".
Form B: Is an identity database, contain basic details of persons, such as name, surname, membership in DB, and so forth.
The PK between the two forms is a Person Identity, in the format "UID - Lastname, Firstname"
(These fields appear in Form B as separate columns, but in Form A, displays as one concatenated string in a dropdown box, field name Reward_Member
).
Objective:
Form B has a column called Total_Points
, which needs to display a sum of all Points_Earned
for the specific UID.
The SQL expression is similar to: select SUM(Points_Earned) from Form_A where Reward_Member = Form_B.UID + " - " + Form_B.Lastname + ", " + Form_B.Firstname;
Problem:
I'm unsure how to execute the aforementioned logic in Deluge. I have tried the Aggregate method, but it doesn't seem to count the sum of the records, and the Knowledge Base articles aren't of much help either. The result remains blank.
This is the script I have used to try to display the Sum (placed in EDIT>>ON_LOAD):
//Variables
curpts = 0;
emp_lookup_val = input.Employee_ID + " - " + input.First_Name + ", " + input.Last_Name;
//Perform the sum aggregation function
curpts = Add_Loyalty_Entry[Reward_Member == input.Employee_ID].sum(Points_Earned);
//Set the Text Field Total_Points with the calc result
input.Total_Points = curpts;
Example Data:
Form A:
+---------------+---------------+
| Reward_Member | Points_Earned |
+---------------+---------------+
| 1 - Doe, John | 3 |
| 1 - Doe, John | 2 |
| 4 - Crow, Bob | 1 |
+---------------+---------------+
Form B:
+-----+-----------+----------+
| UID | Firstname | Lastname |
+-----+-----------+----------+
| 1 | John | Doe |
| 4 | Bob | Crow |
+-----+-----------+----------+
DEBUG INFO
I used the following expression to see what the data stored in Reward_Member
looked like, and got the result showed after the expression:
Expression: alert input.Reward_Member.toString() + " earned " + input.Points_Earned + " Point(s).";
Result: 3485853000000015046 earned 1 Point(s).
... Looks like BigInt