Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms Pro › Using result of script field in search
- This topic has 5 replies, 3 voices, and was last updated 2 weeks, 5 days ago by
Peter Riley.
-
AuthorPosts
-
August 24, 2025 at 12:05 PM #52867
Peter RileyParticipantMy home brew database has a record for each beer recipe and each record has a table field where I log each brew of that recipe. One of the table’s fields is Quantity (number of bottles produced) per brew, so there are usually several rows in the table. The main recipe record has a Total field that is a script field to sum the remaining bottles from the table Quantity field with this code:
record.getTotalOfLinkedFieldForField(linkedFieldID, fieldID);
to populate it, where
linkedFieldID
is the table ID andfieldID
is the Quantity field.I have a search named ‘Brew Some More’ to filter the records where Quantity = 0. That works OK, but if I edit the search criterion to be ‘Quantity is less than or equal to 2’ I get beers with 11 bottles remaining, but not those with 4 or 8. I suspect I have a data type issue maybe?
Attachments:
You must be logged in to view attached files.August 24, 2025 at 3:07 PM #52869
Daniel LeuParticipantIs the table you’re revering to the Inventory table? Looks like you just discovered a but where the TFF file doesn’t contain the fields inside the table.
In your script field, it might be that the result is interpreted as a string and not an number. You might want to try to use
return parseInt(total);
and set the return type accordingly. I don’t have the content of your script field so I’m just imagine what you might do.Good luck and cheers!
Attachments:
You must be logged in to view attached files.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksAugust 25, 2025 at 1:53 AM #52874
Peter RileyParticipantThanks Daniel and yes, it’s the Inventory table, which should look like the attachment.
My field script for the Total field is this:
record.getTotalOfLinkedFieldForField('fld-ac6d9e3d03ae441994ff64b37ebba4f4', 'fld-b02673a0fe39401583e737a0876998e6');
The interesting thing is that if I change the brew that currently has a total of 11 remaining bottles to a number less than 10 it works, so I guess you’re right in that the Total field is being interpreted as a string and therefore the search for a number less than 3 fails because it parses the first ‘1’ of ’11’ only. Using
return parseInt(total)
as follows doesn’t seem to make a difference (the console in the editor correctly displays 11):function return_total() { var total = record.getTotalOfLinkedFieldForField('fld-ac6d9e3d03ae441994ff64b37ebba4f4', 'fld-b02673a0fe39401583e737a0876998e6'); return parseInt(total); } return_total();
Thanks
-
This reply was modified 2 weeks, 5 days ago by
Peter Riley.
Attachments:
You must be logged in to view attached files.August 25, 2025 at 9:20 AM #52879
BrendanKeymasterI’ve just fixed the bug with exporting a TFF file for a form that has a Table field in it.
August 25, 2025 at 9:33 AM #52880
BrendanKeymasterPeter,
Your Result Type for your Total Script field is set to Text. Try setting it to Number and see if that solves your issue.
Thanks,
Brendan
August 25, 2025 at 10:58 AM #52882
Peter RileyParticipantAh, thanks Brendan. Apologies – I hadn’t spotted that switch before.
All working fine now.
Regards
-
This reply was modified 2 weeks, 5 days ago by
-
AuthorPosts
You must be logged in to reply to this topic.