Update a triggered action
You can update a triggered action to change:
- the object and filters used to identify the trigger
- the configuration of the action, such as the template of the SMS message being sent
- the URL of the external web service being called
- enable or disable the triggered action
To update a triggered action use either the Skedulo API or the Skedulo CLI.
List existing triggered actions
Via the API
To list existing triggered actions, use the GET
call to the /triggered_actions
endpoint.
This returns a JSON response with the following information:
id
: The ID of the triggered action.name
: The name of the triggered action.trigger
: The trigger configuration, including theschemaName
,filter
, andtype
.action
: The action configuration, including thetype
,url
,headers
, andquery
.customFields
: Any custom fields associated with the triggered action.created
andupdated
: The date and time the triggered action was created and last updated.enabled
: Whether the triggered action is enabled or not.
Via the CLI
To list existing triggered actions, run the following command:
sked artifacts triggered-action list
which will return a response such as:
✔ Fetching TriggeredAction list...
name
──────────────────────────
Job status updated
my-test-action
Each triggered action can then be retrieved by name by running the get command, for example:
sked artifacts triggered-action get --name "Job status updated"
Update an existing triggered action
Via the API
Updating an existing triggered action is similar to creating a new one, however, you do not need to include all fields in the JSON payload. You only need to include the trigger or action configuration you want to change, or you can selectively update the name
or customFields
fields.
To change an existing triggered action, make a PATCH
request to the /triggered_actions/{id}
endpoint. You can obtain the ID of the triggered action from the response to the GET
call to the /triggered_actions
endpoint.
For example, to change the name of the triggered action, send a PATCH
request to the /triggered_actions/{id}
endpoint with the following JSON payload:
{
"name": "Updated triggered action name"
}
Example
The following example shows how to update a triggered action to change the filter used to identify the record change that triggers the action.
In Create a triggered action for modified objects, we created a triggered action that sends an SMS message whenever the JobStatus
of a job changes. In this example, we will update the filter
on the triggered action so that an SMS message is sent when the job Start
value changes, indicating that a new time has been scheduled for the job.
To do this, we need to identify the ID of the triggered action, then send a PATCH
request to update the filter
field of the triggered action to fire when the Current.Start
field and the Previous.Start
values change.
- Obtain the ID of the triggered action that you want to update.
- Send a
PATCH
request to the/triggered_actions/{id}
endpoint, where{id}
is the ID of the triggered action you want to update. Include the following configuration in the JSON payload:{ "trigger": { "schemaName": "Jobs", "filter": "Current.Start != Previous.Start", "type": "object_modified" } }
- Successfully updated triggered actions show a
200 OK
response. You can also use theGET
call to the/triggered_actions
endpoint to confirm the changes have been applied.
Note that in the provided example, the entire trigger
object configuration is included in the JSON payload, not just the filter
field. This is because the PATCH
request replaces the existing configuration with the new configuration and all fields are required.
Attempting the above request with a field missing, for example, the type
field, will result in a 400 Bad Request
error with the following message:
[
{
"errorType": "field_error",
"message": "Missing required field",
"path": ".trigger.type"
}
]
Via the CLI
A triggered action can be updated via an artifact state file by running the upsert command, for example:
sked artifacts triggered-action upsert -f job-status-change.triggered-action.json
This finds the triggered action using the name
in the state file, and then replaces that triggered action with the data from the state file.
If you need the state file of an existing triggered action, see the “List existing triggered actions” section above.
Limitations of updating a triggered action
Updating a triggered action cannot change the type of action. That is, you cannot update a triggered action to change it from sending information about a record change as an SMS via the send_sms
action to instead sending the change to an external web service via the call_url
action type.
Attempting to do so will result in a 400 Bad Request
error with the following message:
{
"errorType": "invalid_triggered_action",
"message": "Cannot change the type of the action"
}
Feedback
Was this page helpful?