Skip to main content

message.put

message.put(key, value)

Description

Adds or replaces a field in the message.

Parameters

ParameterTypeExplanation
keyStringField name (use a / between field names when the field is within another field)
valueObjectThe value to set the field to

Example

// Put a boolean in the message
message.put("critical", true)

// Put a int in the message
message.put("impact", 5)

// Put a map in the message
map = new HashMap<String,String>()
map.put("element1", "value1")
map.put("element2", "value2")
map.put("element3", "value3")
message.put("map", map)

// Put if a field has changed
if(message.changed() && message.get("ticket/priority") != message.previous().get("ticket/priority"))
message.put("/ticket/newnote", "The priority has changed from" +message.previous().ticket.priority+" to"+message.ticket.priority);