EXAMPLE 04 OF 16 · Starter
Remember a value
Read a workflow State key, save a message, and confirm that the next run remembers it.
Before you begin#
- Use the Browser runtime and keep browser storage available. This example only writes the greeting key in its own workflow State.
Walk through the workflow#
- Import a new copy and run it once. The first Get State node reports found: false because the copy starts with no saved greeting.
- Set State saves the text Hello from a previous run. The final Get State reads it back with found: true.
- Run the same workflow again. The first Get State now finds the saved value before the write occurs.
- To start fresh, import another copy. State belongs to each workflow and the runtime where it runs; it is not included in downloaded files.
Compare two runs#
On a fresh copy, the first read reports found: false. The last read reports found: true and value: Hello from a previous run. On the second run, the first read also finds that saved value.
Make one change#
Add Delete State after the final read with Key set to greeting. On the next run, the first read should report found: false again.
If it does not match#
Use the same workflow copy and runtime for both runs. State is local to that pair. Importing another copy or changing runtimes gives you different State; exporting a workflow does not carry stored values.