Set Dictionary Value
Set Dictionary Value
Section titled “Set Dictionary Value”Type: dict-set · Package: Collections Activities v1.0.3 · Output: none
Sets or updates a key→value pair in a dictionary. If the key does not exist, it creates it; if it already exists, it replaces its value.
How it works
Section titled “How it works”Puts value under key (converted to text) in the dict dictionary. It modifies the dictionary directly: any variable pointing to it sees the change. The value can be of any type, including null.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
dict | Dictionary | — | The dictionary. |
key | string | — | The key (text). |
value | object | — | The value to assign. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”This activity does not return a value; it modifies the dictionary in place.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'dict' must be a Dictionary, got …. | dict is not a dictionary (the message shows the type received, or null if the variable is empty). Create it first with Create Dictionary. |
'key' cannot be null. | The key expression returned null. |
Example
Section titled “Example”Accumulate the total sold per city:
Create Dictionary → output: totalsByCityFor Each items = sales itemVariable = s └─ activities: Set Dictionary Value dict = totalsByCity key = str(s["City"]) value = num(dictGet(totalsByCity, str(s["City"]))) + num(s["Total"])Related activities
Section titled “Related activities”- Get Dictionary Value — read a value.
- Dictionary Contains Key — check whether the key exists.