Error when creating note in Craft

Newbie here, thanks in advance for any help. @FlohGro posted an action Create Craft Note and I’m unable to get it to work. It needs configuration before first use:

You can get it by copying the deepplink of a document in this space. Paste the link into a new draft and extract the combination like “2159f404-e3ed-4d8a-fbe1-6c361399c8f3” after spaceId= in the link. replace “unconfigured” with this id in the spaceID variable of the script.

I obtain the deep link in Craft, extract the SpaceID, and replace “unconfigured” in 2 places in the action (line 7 and line 9). I’m unsure of whether to leave the quotes around the variable so I’ve tried it both ways. With quotes I get an error of “the SpaceID variable was not configured in the script” and without quotes I get an error of “Syntax error: no identifiers allowed directly after numerical literal”.

Here is the @FlohGro script for reference:

> // created by @FlohGro
> 
> // create Craft note
> 
> // insert your preferred space ID for a document here. You can get it by copying the deepplink of a document in this space. Paste the link into a new draft and extract the combination like "2159f404-e3ed-4d8a-fbe1-6c361399c8f3" after spaceId= in the link. replace "unconfigured" with this id in the spaceID variable.
> 
> const spaceID = "unconfigured"
> 
> if(spaceID == "unconfigured"){
> 
> let errorMsg = "the spaceID variable was not configured in the script"
> alert(errorMsg)
> context.fail(errorMsg)
> 
> } else {
> let title = draft.displayTitle
> 
> let content = draft.processTemplate("[[body]]")
> 
> const baseURL = "craftdocs://createdocument?"
> 
> var cb = CallbackURL.create()
> cb.baseURL = baseURL
> cb.addParameter("spaceId",spaceID)
> cb.addParameter("title",title)
> cb.addParameter("content",content)
> cb.addParameter("folderId","")
> cb.waitForResponse = false
> cb.open()
> 
> }

Thanks for using the action, you only should replace the „unconfigured“ in line 7 (the declaration of the variable)
The quotes are needed to declare this variable as string.

Hope that helps

3 Likes

So simple. Thanks @FlohGro , that fixed it. Thanks for contributing the action too!

2 Likes

Hi @FlohGro, the create new note script works perfectly for me as well however, the append one does not.

After supplying the spaceID and blockID and activating the action. I action log shows the the step is completed, I get a new line in the relevant craft page. However the line is empty!

Just wondering if the append script action still works or am I missing something!?

Thanks!

Hi,
please update the actions - I assume you just had one line you wanted to append / prepend to a craft note. The actions where just using the „body“ of a draft. I updated them to use the whole draft.

:+1: working now!! Thanks :pray:

1 Like

@FlohGro I still get the exception

No identifiers allowed directly after numeric literal

after pasting in the ID in line 7, within the quotes

Do you talk about the append to action or the create note action for Craft ?

Sorry- the create note action

How did you retrieve the ID? And are you sure that it looks similar to the comment in line 5?

Did you change anything else in the script?

I suggest that you download the action again and paste your space ID into the quotes in line 7. this should work out of the box - I tried it again and I’m using this action daily