Hello, I’m a bloody beginner in scripting.
I want to adapt the Append to Craft Note Action by @FlohGro (thank you for sharing) to insert the current date before appending the text.
I’ve tried it with a “let” declaration and inserted "cb.addParameter(“today”,today).
Here’s the script:
const spaceID = “6743b144-fb98-6a79-f6f0-be8a128673ee”
const parentBlockID = “76A760B2-2933-4D0C-879E-EC70C5CEC0F5”
if(spaceID == “unconfigured” || parentBlockID == “unconfigured”){
let errorMsg = “the spaceID & / or the parentBlockID variable was not configured in the script”
alert(errorMsg)
context.fail(errorMsg)
} else {
let content = draft.processTemplate(“[[draft]]”)
let today = new Date()
const baseURL = “craftdocs://createblock?”
// index needed as high number to append the content at the end of a craft document
const index = 100000
var cb = CallbackURL.create()
cb.baseURL = baseURL
cb.addParameter(“spaceId”,spaceID)
cb.addParameter(“parentBlockId”,parentBlockID)
cb.addParameter(“index”,index)
cb.addParameter(“today”,today)
cb.addParameter(“content”,content)
//cb.addParameter(“folderId”,“”)
cb.waitForResponse = false
//let result = cb.open
cb.open()
}
Good news: No error message.
Bad news: Nothing will be inserted (the script is running like before).
Thanks for any help.