Drafts Action Directory

Add Recipe to ShoppingList

Posted by @mtedewards, Last update about 2 months 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
Install

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

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.