NotePlan callback with creation time?

I’m starting with the Append action in this group- Send to NotePlan | Drafts Directory

I’m trying to modify this action to add the creation time and an H2. In another action, I’ve used this format

 ## [[created|%I:%M %p]]

But I’m not sure how to add it in this script

Here’s the current script:

const baseURL = "noteplan://x-callback-url/addText";

var when = Date.parse('today');

var today = (when.toString('yyyyMMdd'));

var cb = CallbackURL.create();
cb.baseURL = baseURL;
cb.addParameter("noteDate", today);
cb.addParameter("text", draft.content);
cb.addParameter("mode", "append");
cb.addParameter("openNote", "yes");

// open the URL. NotePlan doesn't deliver an answer, so any success report will fail.

cb.open();

:slightly_smiling_face: Thanks for any help!

You can use the same template tags via script, using the draft.processTemplate function.

// create a string template that will use put the heading with the timestamp
// then two line feeds, then the content of the draft
const template = `## [[created|%I:%M %p]]

[[draft]]
`
//process that template to replace tags
const text = draft.processTemplate(template)
// use that text as the text parameter
// this replaces the line cb.addParameter(“text”, draft.content)
cb.addParameter("text", text)
1 Like

Thanks so much for the quick and correct reply. It works perfectly!

2 Likes