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]]