Name of Macro in action

I want to place an action inside a macro, when ever that action is triggered what ever the name of the macro is which it is inside I would like to save that name as a variable. Is this possible if so how? I would be using this this system in multiple macros.

Here’s a link to an example macro that can be used to get a macro’s name and UUID

And here’s a link to the KM wiki page for the MacroNameForUUID token

These two resources should take you a long way towards figuring out how to do this, but feel free to ask more questions if you need further help.

1 Like

Use the %ExecutingMacro% token:

Result:

_[test] Set Variable to Macro Name.kmmacros (2.2 KB)


You find the available tokens when you open the Insert Token menu of an action:

Edit/Correction:

%ExecutingThisMacro% is the correct token to get the name of the macro that contains the action
(not %ExecutingMacro%). See the summary below.

3 Likes

Hi,
Thank you both for your support. I have replicated the macro on my end and the result for me is 'Trying'

This is because you have executed the macro with the Try button or with the Try menu item or with the ⇧⌘T shortcut.

Execute the macro normally (for example with a hotkey trigger) and the variable will be set to the name of the macro.

When I execute the action in Macro1 by executing Macro1 in Macro2 I get the result of Macro2....

The actual result should be 'Macro name?' not 'Execute a Macro'

The %ExecutingThisMacro% token should work. It is also in the Token menu (see the screenshot above).

1 Like

PERFECT. I am much obliged for your assistance.

Yes, sorry, my fault. (You have correctly asked for name of the macro where the action is inside.)

To sum it up:

%ExecutingThisMacro%

Name of the macro that contains the action.

%ExecutingMacro%

Name of the executing macro. (Can be the same as %ExecutingThisMacro%, or the name of the macro that is executing the macro that contains the action.)

Wiki 1, 2.

1 Like

Ok, here is my problem. I am running this macro in the background from another macro. :slight_smile:
Thats why I am still getting trying. Please see attached.

I should get this result 'BT DSAR Waiting on evidence that PPI was not charged - Tracer'
However it only works in the testing macro (attached) how can I get it to work elsewhere?

Where does it start?

  1. BT dsar Waiting on evidence
  2. Template letter automation macro
    3.Opportunity costs line item for Project Letter Meging

Weird. When I launch a macro from another macro then %ExecutingThisMacro% gives me the name of the macro that contains the action – even if I run the launcher macro with the Try button.

It seems you have only uploaded screenshots, not the macros. Please upload the macros, or better: before uploading, reduce the macros to minimal working examples (i.e. remove any actions that are not related to the token issue, and remove dependencies on unrelated third-party programs like “Daylite”).

(Of course, make a copy of your original macros before.)

1 Like

Matter has been resolved when we run the macro in the course of our work we do not get the ‘trying’ result

1 Like

Thanks for the feedback!

Would you still like the macros for your own reference?

I don’t need them, but nevertheless you could add a download link to your post above, if you like. So, other people who are working on a similar thing could use your macros as starting point.