copyToPayload
A Workflow Engine function that copies a value to the payload in workflowContext
for the current object. This can be a specific value, or a substitution for an existing object, such as $custom_info.myvalue
.
This function is available as a feature of the Workflow Engine v1.2 download and later.
This function is available for event, alert, and Situation workflows.
The workflow sweep up filter applies to this function.
Back to Workflow Engine Functions Reference.
Arguments
Workflow Engine function copyToPayload
takes the following arguments:
Name | Required | Type | Description |
---|---|---|---|
| Yes | String | Key in the payload to insert data. |
| Yes | String | Value to insert into |
Example
The following example demonstrates typical use of Workflow Engine function copyToPayload
.
As part of an alert data export you have a basic payload map defined called "AlertExport", which generates a map with the following keys and values:
{ “alertId”: "$alert_id", "summary": "$description" }
At export time, you want to include the location, but the data is stored in different places in different alerts: either ci.location.city
or ci.location.dc.
Additionally you want to add the current time to the alert.
The solution is as follows:
You create two workflows: one to add data from
custom_info.location
, the other fromcustom_info.datacentre
.You have already configured default values for these properties, so you can create entry filters based on them. For example, an entry filter of
custom_info.location.city != 'Unknown'
ensures you are only copying data from alerts that havecity
set to a non-default value.You use the
copyToPayload
function to copy from the correct key into the payload using the following actions:createPayload
configured with the map name (AlertExport).copyToPayload
for alerts within the city, withpayloadKey
set to"location"
andvalue
set to$custom_info.location.city
.copyToPayload
withpayloadKey
set to"currentTime"
andvalue
set to$moog_now
.exportViaRest
configured with the endpoint name.
This configuration ensures your payload contains the additional data and exports to an external REST endpoint. The final payload is a combination of your base payload and the additional keys you have added to it:
{ alertId: 11, summary: 'Ping fail 10.0.0.1', currentTime: 1576154788, location: 'London' }
The actions returns true
if the data successfully copies to the payload. If the data did not successfully copy, or the function did not find the payload you specified, it returns false
.