Skip to content

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.

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.

ParameterTypeDefaultDescription
dictDictionary—The dictionary.
keystring—The key (text).
valueobject—The value to assign.

None.

This activity does not return a value; it modifies the dictionary in place.

MessageCause 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.

Accumulate the total sold per city:

Create Dictionary → output: totalsByCity
For 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"])