Home > Software design >  Adding Items from Lists to Dictionaries in Apple Shortcuts
Adding Items from Lists to Dictionaries in Apple Shortcuts

Time:07-21

I have this Shortcut which queries a Notion database, then fetches the IDs and titles of pages from the database and turns them into key : value pairs.

shortcut

I want to add those key : value pairs to the dictionary shown at the top of the screenshot. The problem is, even though I can see that I'm adding to the dictionary inside the Repeat With Each Item loop -

alert screenshot

When I check the contents of my Categories dictionary at the end of the Shortcut, those entries haven't been saved.

I have seen setting variables screenshot

I'd be very grateful for any pointers here.

CodePudding user response:

I figured out the problem - I needed to set the dictionary as a variable outside the loop -

categories dictionary

And then I can update the dictionary inside the loop -

enter image description here

I don't know why that works but it does ¯\(ツ)

  • Related