[Solved Callback: Things and Day One

Hi there, I took @RosemaryOrchard 's awesome things and bear action and tried to turn it into Things and Day One

I will share the scripts below, but it keeps getting hung up at the end. It does not complete.
It moves the items to things, opens Dayone and copies the data to day one, but it doesn’t complete.

I honestly have no idea what I am doing so will someone please help me complete this action pair.

Here are the two scripts.

Script:
// check to see if draft is blank
var content = editor.getText();
var check = content.length;
var taskList = “”;

if (content.length == 0) {
alert(“Draft is blank”);
context.cancel(“Draft was blank”);
}

// Call API for each line in a draft
// split draft and loop over lines
var lines = content.split("\n");

var thingsTask = Array();

for (var line of lines) {
if (line.startsWith("")) {
task = line.replace("
", “”).trim();
temp = TJSTodo.create();
temp.title = task;
thingsTask.push(temp);
taskList += task + “\n”;
content = content.replace(line + “\n”, “”);
}
}

if (thingsTask.length) {
var container = TJSContainer.create(thingsTask);
var cb = CallbackURL.create();
cb.baseURL = container.url;
var success = cb.open();
if (success) {
console.log(“Tasks created in Things”);
content = content + “\n\nTasks collected:\n” + taskList;
editor.setText(content);
} else {
context.fail();
}
}

Callback URL
dayone2://post?entry=[[draft]]

Day One doesn’t support x-callback-url so it can’t /won’t return to Drafts. Bear does, and so will.

Thank you for responding.

Is there something I can do to make it happen? Change something?

Maybe something round tripping through Shortcuts? It depends how Day One is now supporting the latest Shortcuts intentions; or not.

Thank you @sylumer, you made me think about it a little more and I just changed the action step to be a URL from a Callback Url, It worked perfectly, and it wouldn’t have happened without your guidance.

1 Like