Shopping List

Viewing 19 reply threads
  • Author
    Posts
  • June 7, 2021 at 12:15 PM #44557

    robinsiebler
    Participant

    Someone expressed and interest in this, so I am uploading it. Thanks to Sam for all his help!

    This is a simple Shopping List. There are 3 forms. The actual shopping list form, a category form and a products form (which contains the items to populate the shopping list with).

    Adding an item to the shopping list is done via a Siri Shortcut (see attached screenshot).

    The expected input to the shortcut is <number> item. If a number is not provided, 1 is assumed. For example, you could say ‘3 Peaches’ or ‘Heavy Cream’.

    When an item is added to the shopping list, it will see if it exists in the product form. If it does, the item will be also given a category (if it exists). If the item does not exist, it will be added to products, but it will not have a category (this will have to be added manually).

    Items are sorted in the Shopping List alphabetically, by category.

    There is only 1 script ‘Get Item From Clipboard’ and it does all the work.

    Enjoy!

    Attachments:
    You must be logged in to view attached files.
    June 7, 2021 at 4:24 PM #44564

    robinsiebler
    Participant

    I added a script (Combine Items) to combine duplicate items into one.

    function combineItems() {
    	// Combine duplicate items into one item
    
    	var dict = {};
    	var records = form.getRecords();
    	var item_id = 'fld-097c3d751c854b1fb4b528238d48b2c4';
    	var quantity_id = 'fld-285e2c9de4924b7fbba2fd8311ceb625';
    
    	for (var i = 0, count = records.length; i < count; i++){
    		item = records.getFieldValue(item_id);
    		quantity = records.getFieldValue(quantity_id);
    		record_id = records.getId();
    
    		if (dict[item] === undefined) {
    			dict[item] = [quantity, record_id];
    		} else {
    			dict[item][0] = dict[item][0] + quantity;
    			form.deleteRecord(records);
    			rec = form.getRecordWithId(dict[item][1]);
    			 rec.setFieldValue(quantity_id, dict[item][0]);
    			form.saveAllChanges();
    		}
    	}
    }
    
    combineItems();
    June 7, 2021 at 6:05 PM #44565

    robinsiebler
    Participant

    I added over 200 products to the products database and also added the ‘Combine Items’ script

    Attachments:
    You must be logged in to view attached files.
    June 9, 2021 at 1:54 AM #44571

    Roger Cuthbert
    Participant

    Just what I have been looking for. It’s good to see people still using TapForms. Thanks.

    June 9, 2021 at 2:33 AM #44572

    robinsiebler
    Participant

    I fixed some bugs and added a notes field. I also added another 100 products to the products form. In addition, I updated the Shortcut to prompt for a note (see screen shot). However, Siri is stupid! If you say ‘No’ when you are prompted for a note, Siri bails on the entire script! So, instead of saying ‘No’, say ‘Later’ and you will not be prompted for the note.

    I should mention that you have to manually create the Shortcut using the attached screenshot as a guide. I have no clue how to share a shortcut outside of the Apple ecosystem.

    Attachments:
    You must be logged in to view attached files.
    June 9, 2021 at 10:41 AM #44580

    Roger Cuthbert
    Participant

    When I add items to the shopping List form by selecting them manually from the dropdown that picks from the Product Form it doesnt bring over the category into the shopping list form.

    Not sure if it does when using Siri though.

    Any thoughts on how to fix that?

    June 9, 2021 at 11:06 AM #44581

    robinsiebler
    Participant

    I never intended it to be done manually (since I originally wrote this for my wife, who would do it via dictation). Let me look into it!

    FWIW, it works just fine via the shortcut.

    June 9, 2021 at 12:18 PM #44582

    Roger Cuthbert
    Participant

    I’ve tried with Siri and it still creates just the item without a Category at my end ?

    June 9, 2021 at 12:51 PM #44583

    robinsiebler
    Participant

    And the item you are adding is in the Product form and has a category? If so, could you try this? Add the item in question to the clipboard and just run the script ‘Get Item from Clipboard’. Let me know what happens.

    June 9, 2021 at 3:06 PM #44584

    Roger Cuthbert
    Participant

    I added Naan manually and the shopping list record did not add the category.

    I created a shortcut as you suggested. Added Naan to the clipboard and ran your script and the category is added correctly.

    June 9, 2021 at 3:13 PM #44585

    robinsiebler
    Participant

    SO just to verify:
    1. If you manually add an item to the Shopping List, the categopy is not added.
    2. If you manually run the script, the category is added.
    3. If you run the Shortcut the category is added.

    If all of that is true, I think all that I have to do is a add a field script to the Shopping List form that will update the category.

    I will try that and get back to you.

    June 9, 2021 at 3:36 PM #44586

    Roger Cuthbert
    Participant

    I’m in the uk. I will check in the morning. Thanks so much for helping.

    June 9, 2021 at 8:07 PM #44587

    robinsiebler
    Participant

    Fixed!

    Attachments:
    You must be logged in to view attached files.
    June 9, 2021 at 11:26 PM #44589

    Roger Cuthbert
    Participant

    Excellent. Thanks. Tested and working.

    I would add just one more thing, a checkbox field (in my trolley) to the shopping list form to tick when you have the item. And if the filter is showing unticked items the user will only see items still left to buy.

    Great set of forms thanks so much.

    June 10, 2021 at 1:14 AM #44591

    robinsiebler
    Participant

    Ok, I added the checkmark field. In addition, I added a Search Filter for unchecked items and a script you can use to remove checked items.

    Attachments:
    You must be logged in to view attached files.
    June 10, 2021 at 5:39 AM #44593

    robinsiebler
    Participant

    Minor code cleanup and fix for Siri stupidity

    Attachments:
    You must be logged in to view attached files.
    January 26, 2022 at 1:51 AM #46448

    Yvette M
    Participant

    How come I can’t import this into Tap Forms? I’m on an iPhone with updated Tap Forms. Thanks

    January 26, 2022 at 11:40 AM #46454

    Brendan
    Keymaster

    Hi Yvette,

    The Shopping List is a full database document. So you will need to probably download it to your Mac, unzip it, then AirDrop it to your iPhone. Or if you download it to iCloud Drive you can then launch Tap Forms and open any document, then go to Tools > Backup & Restore, then tap on the Download button. Find the file in iCloud Drive (or wherever you stored it), then select it to download it to Tap Forms. It’ll appear as a backup. You can then tap on it and then tap on the Restore Backup button.

    It will appear as a separate document in your main Documents area. So you’ll need to close the currently opened document to see it.

    Thanks,

    Brendan

    January 26, 2022 at 4:28 PM #46457

    Yvette M
    Participant

    I didn’t know to press the restore button. Got it now. Thanks!

    April 20, 2023 at 11:20 AM #49359

    robinsiebler
    Participant

    I fixed the annoying bug (blank entries in the Product form). The Products form now has 460+ items!

    Attachments:
    You must be logged in to view attached files.
Viewing 19 reply threads

You must be logged in to reply to this topic.