> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-xsoar-8-on-prem/8.12/configure-cortex-xsoar/slas/automate-changes-to-incident-fields-using-sla-scripts.md).

# Automate changes to incident fields using SLA scripts

Scripts in Cortex XSOAR enable you to automate processes. In the context of SLA, you can create scripts that will perform specific actions when the SLA is breached. Each SLA script must include the SLA tag.

You can use an out-of-the-box script and attach it to an incident field.

#### Send an email when the SLA is overdue

Cortex XSOAR comes with an out-of-the-box script, called **SendEmailOnSLABreach**, that sends an email to specific users when the script is triggered. You can add this to any incident field as required. For example, add the script to the Remediation SLA incident, so that when an SLA/Timer is breached, an email is sent automatically. By default, the script sends an email to the incident assignee, but you can manually edit the script to add additional recipients..

#### Stop and start different timers in an incident field

In the following example, you want to stop the Time To Assignment timer when an owner is assigned and start the Remediation SLA timer.

If you have not done so already, download the **CaseManagement-Generic** content pack. This content pack includes the **TimersOnOwnerChange** script.

1. Go to **Settings & Info** → **Settings** → **Object Setup** → **Incidents** → **Incident Fields**
2. Edit the Owner field.
3. In the **Script to run when field value changes** field, add the **TimersOnOwnerChange** script.
4. Save the field.
5. (Optional) Test the field change.
   1. Open an unassigned incident and in the CLI type `!startTimer timeField=timetoassignment`.

      In the War Room, the field returns the new value from idle to running.
   2. Go to the **Incident Info** tab and add an owner.
   3. In the War Room, you should see that the Time to Assignment has ended and the Remediation SLA has started:

      ![](/files/teWfAbfFlHhtmJHxfWzY)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-xsoar-8-on-prem/8.12/configure-cortex-xsoar/slas/automate-changes-to-incident-fields-using-sla-scripts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
