Skip to content

[BUG] {{DATE}} isn't scoped for choices nested under macro when set to variable #2242

Description

@aarontcannon

Describe the bug
When there are multiple nested choices within a macro that all specify {{DATE}} to use a different variable, only the first one gets set and used globally for the whole run. This seems to be specific to setting DATE to use a variable. Other options seem to work.
This also appears to happen when calling multiple executeChoice() functions in a script with different options.date values set.

To Reproduce
Steps to reproduce the behavior in Obsidian:

  1. Create a template that just has {{DATE}} for the content
  2. Create a script that sets two variables: yesterday and tomorrow
  3. Create a quick add macro
  4. Add the above script. Add the above template twice. In the first one, adjust {{DATE}} to use the variable "yesterday". In the second one set it to use "tomorrow". Use {{DATE}} for the filename.
  5. Run the macro
  6. Note only one file gets created, rather than two

Expected behavior
Two files get created one with filename/content equal to yesterday's date, one with filename/content equal to tomorrow's date.

Obsidian Debug Info (required for bug reports)
Please include the full Debug Info from Obsidian to help diagnose your environment:

  • Open the Command Palette (Ctrl/Cmd+P).
  • Run: Show debug info.
  • Click: Copy to clipboard.
  • Paste it below inside the code block.
SYSTEM INFO:
	Obsidian version: 1.14.4
	Installer version: 1.14.4
	Operating system: Windows 11 Pro 10.0.26300
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 1
	Plugins enabled: 1
		1: QuickAdd v2.32.1

RECOMMENDATIONS:
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Activity

  1. changed the title [-][BUG] {{DATE}} isn't scoped for choices nested under macro[/-] [+][BUG] {{DATE}} isn't scoped for choices nested under macro when set to variable[/+] on Oct 16, 2026
  2. chhoumann commented on Oct 16, 2026

    @chhoumann
    Owner

    Hey @aarontcannon! Thanks for the report, and for the clear repro steps. They made this easy to pin down. I could reproduce it, and it's fixed in #2243, which will ship in the next QuickAdd release.

    QuickAdd remembered the day the first Template picked, and kept using it for the rest of the macro. So your second Template, set to tomorrow, got yesterday's date too, and both tried to write the same file. Now a choice's Which day only applies to that choice and to anything it runs itself. A Macro's own Which day still applies to every choice inside it.

    I tested it in Obsidian with your setup: a template with just {{DATE}}, a script that sets yesterday and tomorrow, and a macro that runs the template twice, once with each variable. Before the fix, it created one file. After the fix, it creates two, each named and filled with its own date.

    About executeChoice(). Scripts are covered too. Each executeChoice() call now gets its own day, whether it comes from options.date or from a date variable the choice reads, and that day no longer carries over to later steps in the macro. One part I couldn't reproduce: repeated calls with different options.date values already worked for me when the called Template's Which day was left on Today. If your script still creates only one file after you update, please paste it here.

    Until the release is out, you can get both files from a script. Leave the template's Which day on Today, and pass the date in each call:

    module.exports = async ({ quickAddApi }) => {
    	const yesterday = moment().subtract(1, "day").format("YYYY-MM-DD");
    	const tomorrow = moment().add(1, "day").format("YYYY-MM-DD");
    	await quickAddApi.executeChoice("Your template", {}, { date: yesterday });
    	await quickAddApi.executeChoice("Your template", {}, { date: tomorrow });
    };

    Replace Your template with your Template choice's name. Let me know if anything still acts up after you update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions