Skip to Content
Back to Actions

Updated

How to Use Global Variables in Shortcuts on iPhone and Mac

With Actions

  1. Install Actions, and open it once.
  2. In a shortcut, add the “Global Variable: Set Text” action.
  3. In the action, type a name for the variable, like lastRun, and the text to save, or choose a variable of the shortcut.
  4. In the shortcut that needs the value, add the “Global Variable: Get Text” action, and type the same name.

There are also actions for numbers (“Global Variable: Set Number” and “Global Variable: Get Number”) and for true or false values (“Global Variable: Set Boolean” and “Global Variable: Get Boolean”). “Global Variable: Delete” removes a variable, and “Global Variable: Get All” gives all of them.

Tips

  • Use a number as a counter, like how many times a shortcut ran today.
  • Use a true or false value as a switch that one shortcut sets and an automation reads, like “at home”.
  • To save several values under one name, save a dictionary as text, and give the result of “Global Variable: Get Text” to the “Get Dictionary from Input” action.

The variables sync with iCloud between your devices. They are for small values: at most 1000 variables and 1 MB in total. For large data, save a file.

Get Actions

Additional actions for the Shortcuts app

Download on the App Store

Free

Platforms
macOS, iOS, visionOS
Requires
macOS, iOS, or visionOS 26 or later
Category
Utilities
Released
October 2021
Updated
June 2026
Version
4.2.0
Size
29 MB
US App Store rating
4.8/5 (529 ratings)

More about Actions

Without an app

Shortcuts can save a value in a file, which works like a global variable:

  1. To save the value, add the “Save File” action. Turn off “Ask Where to Save”, choose a folder, like the Shortcuts folder of iCloud Drive, write a path, like lastRun.txt, and turn on “Overwrite If File Exists”.
  2. To read the value, add the “Get File from Folder” action with the same folder and path, and then the “Get Text from Input” action.

This needs more actions for each value, and a number or a true or false value comes back as text. It is fine for one or two values. The actions of Actions are shorter, and keep the type of the value.