Having had a quick browse through the actions, dictionaries and loops definitely look like they could help simplify the shortcut.
Dictionaries are very much like their book basis. Think of them like a collection of variables. Each entry has a name (called a key) and a value. The value could be text, a number, a true/false, or even a list of items or another dictionary.
Imagine a dictionary of meals. Each meal has several attributes - e.g. a name and a list of ingredients and their quantities. Starting at the most detailed level, we could say that each ingredient might have the following attributes. An ingredient name and a quantity. We could also add a store, but let’s put that aside for a moment.
That’s two key-value pairs so we could make each one of these as a little dictionary.
A set of ingredients is probably reasonably described as a list, so maybe we could make a list of these dictionaries within a recipe? That lists maybe gets a key of “Ingredients”. Then we add another key-value pair for the name of the meal.
We can express dictionaries in something called JSON, don’t worry about the what’s and why’s, but let’s write down a very basic fruit salad recipe as an example so that you can perhaps get the gist of the structure.
“Meal” : “Fruit Salad”,
“Name” : “Pear”,
“Quantity” : 20
“Name” : “Grapes”,
“Quantity” : 200
“Name” : “Mango”,
“Quantity” : 10
You could build a separate dictionary like this for each recipe, or have a list of recipes as a value list within another dictionary. Kind of getting a bit Inception isn’t it?
Now I didn’t include the store against the ingredients, but I certainly could have. If it is an ingredient that shows up more than once, it kind of makes sense to hold that data outside of the recipe in a different dictionary of ingredient information. The principles around this are identical to the ones use to develop efficient databases; but think of it as if you have to change stores for an ingredient, or you are doing costings and the cost of an ingredient changes, you only have to change it in one place, not in a dozen recipes.
The basic premise of building up the ingredients dictionary would be the same as for the recipes above.
But the point about databases does bring up a couple of related points.
- Could using Airtable be more beneficial here than using dictionaries? I feel it would certainly be easier to maintain and read, and they probably already offer a database structure that you could start with and link a Shortcuts shortcut into.
- For all the effort this will take, is there an integrated offer out there. I know the Paprika app has some options around pre-populating grocery lists for example. Even if something doesn’t integrate directly with Things, perhaps it would simplify things enough to make it worthwhile or to the point where it simplifies development of a shortcut to load it into place.
Unfortunately I don’t use Things so there’s a lot of functionality I can’t see in the shortcut - just offers to install the app to get the functionality. As a result I can’t really offer more than that.
End of the day with your shortcut is that if it is working, then maybe look at incrementally tweaking it, or more specifically, a duplicate of your original. It’s a big shortcut, so perhaps it is big enough to warrant an approach of trying to separate it out into smaller, distinct separate shortcuts that you chain together, and then work on streamlining each of the shortcuts.
- A shortcut to build/store/access your recipe information.
- A shortcut that lets you select a recipe.
- A shortcut that lets you review all of the selected meals.
- A shortcut that stores an intermediate set of aggregated ingredient information.
- e.g. Doesn’t store Apples = 5, Apples = 10, but rather just Apples = 15.
- A shortcut that adds all of the ingredients for the selected recipes to the various store lists in Things.
Really sorry I can’t suggest anything further, but hopefully there’s some ideas there that might help you and others who do use Things build something you feel is the next evolution of what you currently have.