Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › How to create a Shopping List database
- This topic has 28 replies, 5 voices, and was last updated 1 year, 8 months ago by robinsiebler.
-
AuthorPosts
-
June 4, 2021 at 6:55 PM #44511
robinsieblerParticipantI couldn’t find a basic shopping list for Tap Forms, and all of the iOS shopping list apps suck, so I guess I need to create my own. Unfortunately, I haven’t used Tap Form in a long time and I have no clue where to start. I just want a basic shopping list (for now) that has an item, a quantity and a category. I also want to be able to use a Siri shortcut (the only way I will be able to get my wife to use this).
Any advice, tips, suggestions, etc. would be greatly appreciated!
Thanks in Advance!
June 5, 2021 at 12:23 AM #44512
BrendanKeymasterHello Robin,
To create a shopping list form:
1. Create your new form by tapping the Add Form button.
2. Add the fields you want to track:Acquired / Checkmark
Item Name / Text
Quantity / Number
Category / Text
Aisle / Number
Description / Note
Photo / Photo3. If the Acquired field is at the very top, you’ll get a Checkmark button on the records list view that you can tap on when you picked up that item.
You would then add in all your items by creating new records and then entering in the Item Name and Quantity and other information that you have about the items.
Then when you’re shopping, just display the list of items and tap on the checkmark button when you pick each one up.
Before you go shopping the next time, you’d probably want to go through the list and uncheck the items that you want to buy again.
If you group the records by the Checkmark field, you can have all of the unchecked ones at the top and all the checked ones at the bottom of the list of records.
Hope that helps a bit.
Thanks!
Brendan
June 5, 2021 at 1:15 AM #44513
robinsieblerParticipantAwesome! Thanks!
June 5, 2021 at 5:39 AM #44515
robinsieblerParticipantSo, I want to create a database populated with items that are associated with a category (and possibly an aisle) so my can select/type/say ‘Eggs’ and it will “know” that Eggs belong to the Category ‘Dairy’ and are in Aisle 14. How do I achieve this? I am guessing that I need a a different form (or table?) that links Eggs to Dairy and Dairy to Aisle 14.
(I did mention that it has been a long time since I used this program; I think I have forgotten anything I knew).
June 5, 2021 at 2:44 PM #44517
Sam MoffattParticipantI have a video series on creating a meal planner from scratch including a shopping list feature showing how that works on iOS. I need to finish editing some follow up videos for it as well but it also has a visual walkthrough from scratch.
You could do another form to encode that knowledge and then use a link to form field to have that show up on your main form. I’d create the other form, use a Link to Form 1:M field back to your main form so that your grocery list has a single item select to search for that and find them. Then in your list form I’d use a calculation field which will let you automatically copy a field from the parent form into the shopping list.
June 5, 2021 at 2:49 PM #44518
BrendanKeymasterIt also really depends on how you want to set things up. Categorizing things can be as simple as a Text field with a Pick List of categories assigned to it or you could go the Link to Form route. Sam’s got some excellent videos of how to achieve that, especially with his mentioned Meal Planner videos.
June 5, 2021 at 3:29 PM #44520
robinsieblerParticipantThanks for all the info! I will be sure to watch the videos!
June 5, 2021 at 5:12 PM #44521
robinsieblerParticipantOk, I am sure I am doing this all wrong, but…you have to start somewhere.
I have a Form called Categories, where I have records for all of the Grocery Store categories (Bakery, Dairy, Meat, etc).
Then I have another Form called Products where a record contains an item name (Steak) and I used Categories as a pick list to choose a category (in this case, Meat).
Then I created a Shopping List Form, where I select an item from the Products form and I can enter a quantity for that item.
However, for the life of me, I cannot figure out how to display the Category that a product belongs to (and ideally, I want to sort based on that category).
Attachments:
You must be logged in to view attached files.June 5, 2021 at 9:49 PM #44524
robinsieblerParticipantSo, I guess the only way to do this is via a script. So, after much experimentation, I came up with a script that I think should work, but doesn’t.
If I attach the script to the record, it seems that it fires immediately and fails, because the record is empty.
If I add it to the scripts section and trigger it manually (which I very much don’t want to have to do), it gets the right value for the category, but fails to change the Category in the record.
A) What am I doing wrong?
B) How to I get a script to fire automatically after an item is selected?function getCategory() { var selectedItem = record.getFieldValue('fld-097c3d751c854b1fb4b528238d48b2c4'); var records = document.getFormNamed('Products').getRecordsForSearchTerm(selectedItem); return records[0].getFieldValue('fld-18643254818f4efbb85cdc66084ccec4'); } function setCategory() { var cat = getCategory(); console.log(cat); record.setFieldValue('fld-104d11f1b0074b328dafd7688e87298c', cat); } setCategory();
June 6, 2021 at 12:09 AM #44526
Sam MoffattParticipantWhen you do a
setFieldValue
you need to also do adocument.saveAllChanges()
to ensure Tap Forms persists the change.Field scripts will trigger automatically when ever a field you refer to in the script changes, including when the record is created initially. If you want to run the script on demand, then you want to create a form script via the third tab instead of a field script. Form scripts only execute when you click the run button for it. If you’re after a situation where if you update a field that it refreshes the value of your target form. Depending on what you’re doing, you can also just use the script field to store the value and if you have a link to form field you can skip the search and traverse the link instead.
I was looking at the document you sent but it seems out of date based on the field ID’s I see here. It does look like you’ve got a form (Categories) that also seems to be a pick list. You can get the pick lists though it doesn’t do the search for you so I’m wondering if that’s why you did it that way? You can also set up the pick list to update based on the form field directly which doesn’t seem to be how it’s configured.
June 6, 2021 at 1:02 AM #44527
robinsieblerParticipantI added saveAllChanges(). That worked. I am not sure what you mean by ‘the 3rd tab’ for scripts; I am doing this on my iPad. I didn’t really understand anything else you said (sorry!). I have attached the latest version of my document.
I can create a Siri shortcut to run the script. Is it possible to have a Siri shortcut where my wife could say ‘Add 3 peaches to Shopping List’ and have it a) create that record and b) run the script to set the item category?
Attachments:
You must be logged in to view attached files.June 6, 2021 at 11:03 AM #44531
Sam MoffattParticipantOn mobile, the form scripts are under the “Customize Form” > “Scripts” or if you tap “Run a Script” you can also get to your scripts and manage them. Forms scripts differ from script fields in that they’re executed on demand versus script fields that are supposed to automatically update.
The way I’ve done this sort of natural language processing is via a script field that uses Javascript regular expressions to match field contents and then update other fields. The reason for this is that if you consider your input (e.g. “3 peaches”) you’re going to want to match “peach” and map that back to a known record.
Siri’s limited in what conversational features it can do and how applications can integrate. The way I’ve worked around this is using Siri Shortcuts to handle the interaction and then call in a form script in Tap Forms. The video uses a barcode scanner use case but you could create a trigger for Siri to ask for the item to add and then use a dictate text to prompt for input.
June 6, 2021 at 11:09 AM #44532
Sam MoffattParticipantScreenshot of a shortcut that prompts for input which you can then put into the other video. Only problem with this technique is that it launches the app and sometimes TF doesn’t load the form first time around. It’s a little easier with CouchDB sync because in that situation I usually write directly to CouchDB from Siri Shortcuts but doing that is a lot more involved.
Attachments:
You must be logged in to view attached files.June 6, 2021 at 12:49 PM #44534
robinsieblerParticipantOk, I actually made a lot of progress! I figured out how to use a Siri Shortcut to send text to the clipboard and get the clipboard in Tap Forms.
I have a new script called ‘Get Item from Clipboard’ (It does more than that, but I could not figure out how to chain scripts [if that is possible]) that retrieves the clipboard, parses it, creates a new record and then…tries to populate it. However, that step is failing for some reason.
Any help would be greatly appreciated!
Attachments:
You must be logged in to view attached files.June 6, 2021 at 2:26 PM #44536
Sam MoffattParticipantYou can use
form.runScriptNamed('Script Name')
to run another form script within the form. I have a script manager form that I centralise and then I can dodocument.getFormNamed('Script Manager').runScriptName('Script Name')
to pull that into my various scripts. This allows you to set up form scripts that are libraries of code that you can use or you can set them up to chain them together as well.Looking at your
getItemFromClipboard
method, you might want to runtoLowerCase
on thenumeric[1]
inside the switch that way if something messes with capitalisation the script doesn’t break.June 6, 2021 at 2:36 PM #44537
robinsieblerParticipantAny idea why the new record is not being populated?
June 6, 2021 at 8:59 PM #44540
NighthawkParticipantIf you get to the point where you want to give up on using TF to create your shopping list, you might want to look at the app ‘AnyList’ (https://www.anylist.com). I’ve used TF for many things but I never got into scripting, so I ran into trouble trying to build my own TF shopping list. I tried AnyList and liked the free version enough to pay the $10 annual fee. Although it can handle meal planning and recipes, I only use it for lists. BTW, it’s also great for ‘To Do’ lists. The best part is that there is a web interface, a Mac app, an iOS app (both iPhone and iPad), an Apple Watch complication, and PC and Android apps (I haven’t used them). You create a free account on their server and the list is immediately synced between all your devices. To be clear, I love TF and I have used it for many things for years, most importantly to keep all our family’s medical records on all our devices and to keep them in sync. I just consider TF to be one tool in my toolbox, and for my shopping lists I found I like the AnyList tool.
June 6, 2021 at 9:04 PM #44541
robinsieblerParticipantI actually tried AnyList, but I can’t get my wife to use it correctly (she only uses voice dictation), so I will get 40 items under Other like ‘Get broccoli for casserole’ and ‘4 Peppers for Susan’, and then I have to parse that at the store.
So I am hoping that I can make a simple program that she can only use 1 way and hopefully that will work…but I am not holding my breath.
June 6, 2021 at 9:10 PM #44542
robinsieblerParticipantI figured out why my record was not populating. However, I don’t know if it is a bug, or user error. I have this code:
var item_id = 'fld-097c3d751c854b1fb4b528238d48b2c4'; var quantity_id = 'fld-285e2c9de4924b7fbba2fd8311ceb625'; newRecord.setFieldValues({[item_id]: item, [quantity_id]: quantity});
It works. Before, I had the below code and it did not work:
var itemField = sl.getFieldNamed('Item'); var quantityField = sl.getFieldNamed('Quantity'); newRecord.setFieldValue(itemField, item); newRecord.setFieldValue(quantityField, quantity);
June 6, 2021 at 9:14 PM #44543
robinsieblerParticipantOk, now I have my basic document/form/script. It runs (Yay!). But when I try to trigger it from a Siri Shortcut, nothing happens and then I get an error saying it too too long to run…
Attachments:
You must be logged in to view attached files.June 6, 2021 at 9:40 PM #44545
robinsieblerParticipantIs there a way to disable the pop up dialog when you run a script?
June 7, 2021 at 12:44 AM #44546
Sam MoffattParticipantThe
getFieldNamed
call will return a TFField object not the field ID that you need. I think to make your code work, you’d need to do:var itemField = sl.getFieldNamed('Item'); var quantityField = sl.getFieldNamed('Quantity'); newRecord.setFieldValue(itemField.getId(), item); newRecord.setFieldValue(quantityField.getId(), quantity);
Personally I use the field ID’s as inserting them is easy enough in the editor.
I also generally use the x-callback interface with the script URL to invoke Tap Forms that way. You can use “Copy Script Link” from the menu in the script editor to get a link.
June 7, 2021 at 2:23 AM #44547
robinsieblerParticipantI fixed all that and I used the x-callback, which works just fine!
Thanks for all your help; you have been a lifesaver!
June 7, 2021 at 8:28 AM #44551
NighthawkParticipantWhen you get your database working properly, will you please consider sharing it with other TF users on the Tap Forms Template Exchange? I’d love to see how it works. Thanks!
June 7, 2021 at 10:05 AM #44553
robinsieblerParticipantI’ll do that! It’s mostly done; the only real thing to do is add a slew of products to the database. Currently, if you add an item to the shopping list, it will also add it to the products database, but it won’t have a category and that will have to be done manually.
June 7, 2021 at 10:59 AM #44556
Sam MoffattParticipantGood to hear you got it all to work together.
January 1, 2023 at 9:18 AM #48545
Yvette MParticipantHi. Just curious, did you ever share your template? I know you worked hard on it- but I’d love to see it in action and use it also if you don’t mind. Thanks!
January 1, 2023 at 10:03 AM #48546
robinsieblerParticipantI did posted it (link below). I have a lot more entries in my database now (and there is a minor bug that needs to be fixed), so I will try to update it in the near future.
April 20, 2023 at 11:23 AM #49361
robinsieblerParticipant@Yvette: I finally fixed that bug and updated a new version. Sorry it took so long!
-
AuthorPosts
You must be logged in to reply to this topic.