Storage: Set Value Node
The Storage: Set Value Node allows a workflow to store or manipulate a value for use in a subsequent workflow run by the Storage: Get Value Node. Stored values can also be viewed and manipulated using the workflow storage tab.
The maximum size of a single value stored by a Storage: Set Value Node is 16KB.
There are multiple configuration properties for the Storage: Set Value Node:
Operation: Determines the method by which to store a new value or mutate an existing storage value. Possible operations include:
- Store Value From Payload Path: When selected, the “Value” field is a payload path, and the value at that path will be added to your workflow storage.
- Store String: When selected, the “Value” field is a string template, and the rendered result will be added to your workflow storage.
- Store JSON: When selected, the “Value” field is a JSON template, and the resolved value will be added to your workflow storage.
- Store Number: When selected, the “Value” field is a number or a string template resolving to one. If the result cannot be cast to a number, the node will error.
- Increment Value: This allows the node to atomically increment a value already in storage. The value in storage must either be a number or not exist (in which case it is treated as 0). If the value in storage is not a number, the node will error. The “Value” field is treated as the amount by which to increment; it must be either a number or a string template that resolves to one. If the value cannot be cast to a number, the node will error. Floating point and negative increments are allowed.
- Decrement Value: This is similar to the “Increment Value” operation, except it lowers the chosen value instead of increasing it.
- Clear Value: This clears out whatever value is currently stored at the given “Key”. When selected, the “Value” input is removed.
- Clear All Values: This clears out all values in your workflow storage. When selected, the “Key” and “Value” inputs are removed.
- Key: The key under which the new value will be stored, or a string template resolving to a key. Depending on the chosen operation, the key may need to be that of an existing value in workflow storage, and the value stored at that key may need to be of a certain value type (i.e. a number).
- Value: Depending on the chosen operation, the format of this input will change as outlined above or may not be set at all.
In the above example, workflow storage is being used as a caching mechanism for a value being fetched from a third-party API using the HTTP Node. In the absence of an existing value in storage, the HTTP Node fetches the value, and it is stored in workflow storage using the Storage: Set Value Node’s “Store Value From Payload Path” operation. On subsequent runs, the Storage: Get Value Node can pull the response from storage using the key under which the value was added to storage.
Optionally, you may provide a payload path in the “Result Path” field so that the result of the storage operation can be placed at that path on the current workflow payload. Depending on the chosen “Operation”, the value at this path differs:
- For “Increment Value” and “Decrement Value” operations, the value placed on the payload will be the storage value after the increment/decrement is applied.
- For the “Clear Value” operation, the value placed at the payload path will be the value at the key that was just cleared.
- For the “Clear All Values” operation, the result is an object with a
removedkey, whose value is the number of storage values that were just deleted.
- For all other operations, the result will be the value that was just stored.