I had a Drafts action that was working to send a note to Craft. I am now getting this error. I have no idea what this means. Suggestions?
Can you share a link to the script so we can take a look? Looks like either a template tag is not specified anymore or something in the code got changed. Could also be if there’s a response that’s being parsed that might have changed. Either way, we’ll need to see the script.
@motopascyyy Thanks for helping! Below is the script. After reading your response, I figured out to locate and open up the script editor in Drafts (I’ve never done that before as I’ve never messed with scripts) and I think I know what I need to do.
I assume that I need to filled in “unconfigured” so that if my Craft space is named work I would enter that between the quotes as “work”. Is that correct?
// 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]]")
content = encodeURIComponent(content)
const baseURL = “craftdocs://x-callback-url/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 = true
let result = cb.open()
if (result == true) {
console.log(“Craft note successfully created”)
} else {
console.log(“Craft note result:” + cb.status + " " + cb.callbackResponse)
if (cb.status == “cancelled”) {
context.cancel()
} else {
context.fail()
}
}
}
You’ll need to update the script to specify the spaceID corresponding to the target Craft Space.
const spaceID = “unconfigured”
As noted in the comments:
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.
@motopascyyy and @timstringer Thanks guys for the help. It took me several tries (I have no experience with scripts or coding of any sort) I got it to work. I also learned that I need to read the descriptions for Drafts actions.
Thanks again!
More importantly, I learned something! Thanks again!
Happy to help and glad it was a productive exercise!
Thanks for the help from the community - as you said I added this to the description of the Action. In other actions for Craft I somehow simplified this for users so they don’t need to edit the script.
Maybe I should update the other actions, too.
If you have any other requests you can ask me
Awesome!
(20) characters