Hi,
I’m writing a script to add notes to the Bear app. The user is prompted to make one of two choices - either to add the item(s) to an existing note or to create a new note. Depending on which option is chosen, a further prompt would appear offering the option to enter/select further options, e.g. flag, title, etc. These would then be mapped to URL parameters to be added to the final URL.
I have written the skeleton of a script (below) and I’m reasonably sure how to generate various input fields for the prompt; however, I’m unsure as to how to do the nested prompt (or even if it’s possible).
let p = Prompt.create();
p.addButton("Append to note");
p.addButton("Create a new note");
if (p.show() === false)
{
context.cancel();
}
let cb = CallbackURL.create();
cb.baseURL = "bear://x-callback-url/";
switch (p.buttonPressed)
{
case "Append to note":
cb.addParameter("add-text")
break;
case "Create a new note":
cb.addParameter("create");
break;
}
cb.addParameter("text", draft.processTemplate("[[draft]]"));
if (cb.open())
{
console.log("Item added to Bear")
}
else
{
console.log(cb.status);
if (cb.status == "cancel")
{
context.cancel();
}
else
{
context.fail();
}
}
Any guidance would be greatly appreciated!
Many thanks,
Martin