Still working to figure out JavaScript here - trying to set up a front-end for sending text to Fantastical and append text to a draft that contains the calendar type. In this simple example below, every time I run the script - and no matter whether I press Work or Home button, the text from the first if statement is added (" /Calendar"). It seems like I am passing the button pressed to the variable in the if statements. Is there something else I am missing here?
Thanks for any pointers!
/*
Ask for a calendar type, add tag to draft based on calendar type
*/
// setup calendar categories
const categories = ["Work", "Home"];
// prompt to select a category
var p = Prompt.create();
p.title = "Select calendar";
for (var cat of categories) {
p.addButton(cat);
}
if (p.show()) { // user made a selection
var calendar = p.buttonPressed;
var d = draft;
if (calendar = "Work") {
d.content = d.content + " /Calendar "
d.update();
} else if (calendar = "Home") {
d.content = d.content + " /Outlook "
d.update();
} else {
}
} else {
context.cancel();
}