Help Wanted: New Notion Database Item Using Drafts

I have been scouring the internet for a solution to this problem I am having.

I found this script and the related thread that would allow one to create a new database item in notion using drafts. Despite reading the thread, watching hours of video on javascript and reading about notion’s API’s… I have been unsuccessful in making it work.

As a result I reached out to a programmer using a freelance website who was able to make the script work for adding a new page in notion. In order to use drafts to make a new database item he claims you need premium version of drafts which he doesn’t have. That said he would need remote access to my desktop in order to complete this job. I am obviously not going to do this So, now I am at a standstill again.

Is anyone currently doing this or willing to help me out in coming up with a solution. Those of us Notion enthusiasts (weirdos that we are) want this functionality. Such that a good percentage of the us are paying zapier $30 a month for just this function.

Honestly, right at the moment, unless you are an experienced JavaScript coder, I would recommend you wait a few months and revisit Drafts <> Notion integration.

While it is possible to use the Notion API directly from Drafts now, it is not integrated into the app and supported. We plan to add Notion integration in the coming months now that their (still in beta) API has settled down and is not changing every few weeks.

1 Like

Problem: The script that allows adding to the Notion Database does not work for the second time…

I’m a Drafts Pro user. I use the Notion integration script to add notes to my Notion database(1). I want to create another connection with another database(2) but it doesn’t work when I duplicate or Install it again.

I tried another database(3) to check the accuracy of the database(2) but it didn’t work also.

Is it a problem with me, or Drafts disabled that function for a second?

I’m currently using the first connection properly. But I can’t create the second one.

Could you point out the action you are using in the Directory, or otherwise share it? Drafts does not have integrated support for posting to Databases, so it must be some community action. Without seeing how it works, it’s hard to troubleshoot.

I’m using this action;

Looks like the DB id is hard-coded into that action. Did you duplicate the action, and change the dbid to the id for the second database you want to target?

Also, did you share the second DB with the Drafts integration as described in the Notion integration guide?

Yes, I duplicated action. And then re-create from scratch when it doesn’t work.

And yes, I shared the databases with Drafts.

What happens when you run the action? Errors? Any details in the action log?

Always shows done :+1:t3:

(I’m sending the screenshots)

That’s what you see happen. Don’t forget the action log details have been requested too.

I couldn’t add another file here as an attachment.
I’m sending it as a link;

Sorry for the lack of clarity. The Action Log is the history of errors and more detailed logs that is available above the action list. I’m not sure what you might find, but it is often helpful:

This is a community developed action, so I can’t really support it directly, but looking at it, it appears you should get an error message unless Notion successfully accepted the post.

Perhaps, @feliz could take a look and suggest what might be going awry.

I’m not sure what is going on without seeing your code.

I have used the action with multiple databases.

Suggestions:

  • check the database ID is correct.

  • check you have registered the database as per agile tortoise instructions.

  • check that the note title (note name) property in your database is called “Name” (the default).
    If you have changed this you will have to change it in the code under “const properties”.

  • start with a new duplicated version of my original in case any errors have slipped in- comma (,) placement is important.

Hope this helps!

Yeah, it’s fixed. Thank you so much. Name property had a different title and I changed it :v:t2:

3 Likes

Hey Feliz, thanks for adding this action it works great! I saw what you mentioned about the default property being Name, and how to change it in the script if we have already changed it in our database. My question is, does the action only map to the first property? I have a pretty extensive database i would like to add this action to, but my “name” property (mine is task) is the 3rd property as shown in the screenshot. Any way I can use it like this, or would I have to change the order of my database properties?

Scratch that question, I thought it wasn’t working at first, but I found the drafts i sent by searching in Notion’s quick find. I figured out they weren’t showing up in my inbox because I have two default properties that need to be enabled on the DB entry for them to show up in the inbox (priority set to medium & Kanban set to To Do), otherwise they are only findable by search. Do you know of a way that can be added to the script? If its asking too much just ignore me :joy:


Hi Andrae, it does not matter how many properties there are in your db or in what order, the ‘Title’ (Aa) property (called ‘Name’ by default) is a unique property used to identify a record, it exists in all databases.
As long as the property is identified as the “title” property, and the name of your title property is the same, and the syntax is correct, it will work :
"Name of your title property": { "title": [ {"text": { "content": title}}]}
:slight_smile:

Hi Andrae, you can hard code other database properties as long as they include the property type, property name and correct syntax. So you could add the extra properties for Status and Priority beneath the Title/Name property:

const properties = { 
					"Name": { "title": [ {"text": { "content": title}}]} ,				
					'Priority': { select: { name: '🧀Medium',},},
					'Kanban Status': { select: { name: 'To Do',},},
					} ;

The select property name and select property option should exactly match the name and option in your database.

Alternatively you could add a condition to your Inbox filter in Notion to capture any records where the Priority is empty.
PS. did not know emoji’s would work but seems to :slight_smile:

1 Like

Thank you so much! It worked perfectly. Also thanks for explaining, how to hard code properties, Ill definitely be experimenting with other databases. I just started a JS course two weeks after HTML & CSS. Its mostly theory so far with some easy exercises, so its cool to see a real use case and how it can evolve over time. Much appreciated :pray:

2 Likes

Glad to hear it worked! Tbh it’s probably not great code - I just hacked it together from the Notion API and examples. You prob know more than me :grin:. Enjoy the course!

2 Likes