> For the complete documentation index, see [llms.txt](https://docs.agilecase.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.agilecase.com/developer-documentation/case-scripting/adding-a-new-script.md).

# Adding a New Script

This lesson will show you how to add your own scripts to AgileCase in order to customize case behaviour.

{% stepper %}
{% step %}

## Add a new script

<figure><img src="/files/hNTZNe35cPgqE7fEZnIF" alt=""><figcaption></figcaption></figure>

To add a new script, first click the "Add New Script" button. This will display the scripting form and allow you to proceed.
{% endstep %}

{% step %}

## Enter script details and set permissions

<figure><img src="/files/wJCgoHpKwm602qjuEVfH" alt=""><figcaption></figcaption></figure>

First of all you should name your new script and enter a short description. You can also select whether the script runs when the page is loaded or when the case is saved.

You can read more about On Load scripts [here](/developer-documentation/case-scripting/on-load-scripts.md) and more about On Save scripts [here](/developer-documentation/case-scripting/on-save-scripts.md).

You can also select which case types the script will be active in.
{% endstep %}

{% step %}

## Add script content

Once you have entered the details of the script, you are free to write the script itself in the "Script Content" box. Users that are familiar with JavaScript will have free reign over their case behavior.

How the script needs to be written depends on when it runs, so if you are starting from scratch it is worth reading [On Load Scripts](/developer-documentation/case-scripting/on-load-scripts.md) or [On Save Scripts](/developer-documentation/case-scripting/on-save-scripts.md) first. Both pages end with worked examples you can adapt by swapping in your own field IDs.

If you have no scripting experience or wish to create especially complex scripts, we can write custom scripts for you. If you are interested in this service, please contact us on <sales@agilecase.com> for more information and pricing.
{% endstep %}

{% step %}

## Save your script

<figure><img src="/files/FdpKjdIwcevieKI5tbPH" alt="" width="248"><figcaption></figcaption></figure>

Once you have completed your script, click the "Save Changes" button at the bottom of the page to save your script and add it to the system.

Alternatively, click "Cancel" to close the form without saving.
{% endstep %}
{% endstepper %}


---

# 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://docs.agilecase.com/developer-documentation/case-scripting/adding-a-new-script.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.
