DMN Context Function

◷ Reading Time: 4 minutes

context

Returns a new context that includes all specified entries.

 context (entries)
  • entries (list of contexts):(Mandatory) – each context item SHALL have two entries having keys: “key” and “value”, respectively.
  • If a context item contains additional entries beyond the required “key” and “value” entries, the additional entries are ignored.
  • If a context item is missing the required “key” and “value” entries, the final result is null.
Example: context([{key: "James", value: 65}, {key:"Karl", value: 45}])
Result: {
"James" : 65,
"Karl" : 45
}

context merge

Returns a new context that includes all entries from the given contexts

 context merge (contexts)
  • contexts(list of contexts):(Mandatory) – list of contexts
  • If some of the keys are equal, the entries are overridden.
  • The entries are overridden in the same order as specified by the supplied parameter
Example: context merge([{Name: "James", Age: 65}, {Age: 60}])
Result: {
"Name" : "James",
"Age" : 60
}
Example: context merge([{key: "James", value: 65}, {key:"Karl", value: 45}])
Result: {
"key" : "Karl",
"value" : 45
}

context put

  • Returns a new context that includes the new entry, or overriding the existing value if an entry for the same key already exists in the supplied context parameter.
 context put (context, key, value)
  • context:(Mandatory) – each context item SHALL have two entries having keys: “key” and “value”, respectively.
  • key:(Mandatory) String
  • value:(Mandatory) Any type
  • A new entry is added as the last entry of the new context. If overriding an existing entry, the order of the keys maintains the same order as in the original context.
Example: context merge([{Name: "James", Age: 65}, {Age: 60}])
Result: {
"Name" : "James",
"Age" : 60
}
Example: context merge([{key: "James", value: 65}, {key:"Karl", value: 45}])
Result: {
"key" : "Karl",
"value" : 45
}
  • Returns the composite of nested invocations to context put() for each item in keys hierarchy in context.

 

 context put (context, keys, value)
  • context:(Mandatory) – each context item SHALL have two entries having keys: “key” and “value”, respectively.
  • keys:(Mandatory) a list of string
  • value:(Mandatory) Any type
Example: context put({Name: "James", Address:{No: 15, Postcode: "3654"}},["Address","Postcode"], "3000")
Result: {
"Name" : "James",
"Address" : {
"No" : 15,
"Postcode" : "3000"
}
}

 

get value

Returns the value of the entry named key from context m.

 get value (m,key)
  • m (Mandatory): context- Each context item SHALL have two entries having keys: “key” and “value”, respectively.
  • key: string (Mandatory)

 

Example: get value ({Name: "James", Age: 65}, "Name")
Result: "James"
Example: get value ({Name: "James", Age: 65}, "Age")
Result: 65

get entries

Produces a list of key,value pairs from a context m

 get entries (m)
  • m (Mandatory): context – Each context item SHALL have two entries having keys: “key” and “value”, respectively.  
Example: get entries({James : 65, Karl : 45})
Result: [
{
"key" : "James",
"value" : 65
},
{
"key" : "Karl",
"value" : 45
}
]

 

Updated on September 12, 2025

Was this article helpful?

Related Articles