Action

Add Recipe to ShoppingList

Posted by @mtedewards, Last update over 6 years ago

Allows you to make a recipe as a checklist, check off the items that you already have, and then add the unchecked items to a list in Reminders called Shopping List.

Also: It then resets the recipe items to all be unchecked.

Expected Formatting:

Ham Sandwhich

- [ ] Bread
- [ ] Ham
- [ ] Butter
- [ ] Cheese

Steps

  • script

    // Add unchecked items to shopping list
    
    var list = ReminderList.findOrCreate("Shopping List");
    var d = draft.content;
    var lines = d.split("\n");
    var newContent = "";
    
    for (var line of lines) {
    	if(line.includes("- [ ]")) {
    		var item = line.replace("- [ ]","");
    		var reminder = list.createReminder();
    		reminder.title = item;
    		reminder.update();	
    	} else {
    	   line = line.replace("- [x]","- [ ]");
    	}
    
    	newContent = newContent + line + "\n";
    }
    
    // do the replacement...
    
    draft.content = newContent;
    
    // alert(draft.content);
    
    draft.update();

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.