Add to List enhancement

I use the Add to List action by @FlohGro all the time. I have one request for further enhancement. When I move the note to the lists, Drafts goes to the List Draft, I would rather go back to the Inbox view. I have tried a few different approaches and haven’t been successful.

Thanks for the help!

Add this code at the ned of the Action:

let d = Draft.query("","inbox",[]);
if (d.length != 0) {
    app.displayInfoMessage("loaded first draft from Drafts inbox");
    //	alert("loading draft with title: " + theDrafts[0].title); 
    editor.load(d[0]);
  } else {
  		app.displayWarningMessage("created new draft, inbox was empty!");
		editor.load(Draft.create());
	}

Thank you very much for sending this over.

I cut and pasted that script to the end of the script. When I invoked the script I got:

Script Error: syntax error: Cannons declare a let variable twice: ‘d’.
Line number: 80,
Column undefined

That looks to be telling you that d has already been initially defined with let already. Since this is to go at the end of the original script, and the existing value of d is presumably irrelevant, try simply removing the keyword let on the first of the additional lines.

1 Like

I tried that, the script ran but it did not go back to the inbox view, it stayed on the new list item.

Thanks for your help

Can you perhaps explain more explicitly what you want to do? “go back to the inbox view” doesn’t have a specific meaning for me.

I’ve tracked down the action you were referencing, and looking at the amendment code I can see what’s going on, but I just don’t understand what it is you want to do.

Here’s what I know.

Current Processing

The script will run and take the content of the current draft and append it to another draft. The other draft is determined through a selection/creation process and through tracking available drafts to use via a unique tag.

After the append is completed, that list draft becomes the most recently modified item in the inbox. now I expect that most people have their workspaces and sort settings such that the most recently modified item appears at the top of their inbox.

If you are the same, then when the additional code runs, it will simply tray and load the first item in the inbox … which may well be the list draft that has just been updated.

What you maybe want to do?

Things that I’m wondering if you want to do are things like.

  1. Go back to the draft that contained the content added to the list.
  2. Go to the next most recently modified draft in the inbox that is not tagged with the unique list tag.
  3. Display the left panel that lists the drafts and set it to show the inbox of the current workspace.

It is certainly possible that I’m way off the mark with those last bits, but does all that make sense and get anywhere close?

I really appreciate you taking the tome on this post.

I believe I want your number 3.

My use case is that I add drafts all day to my inbox. Every morning I go through all the drafts from the previous day. I either send the draft to another app ( todoist, Evernote etc ) or I add it to a list. After I add it to a list I am done with it for that point in time.

I would then like to go to the next untagged draft in my inbox.

Make sense?

Only to a point…

It actually sounds like you were describing number 2 when you got into it, so I’ve proceeded on that basis.

Currently I’ve gone with interpreting this as ‘not tagged as a list’ rather than ‘draft has no tags at all’. If the latter is true, I think you would need to loop over all drafts in the query array and check for tags and remove them if they have any - the ‘untagged’ tag option used in workspace queries doesn’t look to apply here, so it is the long way round. For now I’ve gone with the former and used an explicit exclusion of the tag in the search query.

The action finds the next most recently modified inbox draft that isn’t the current one and isn’t tagged as a list; but failing that it will then create and load a new draft.

This revision is wholly based on the original action by and response above from @FlohGro. If it sounds closer to what you want, please give it a try. If not, please provide further clarifcation.