> 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/on-save-scripts/examples/update-case-information.md).

# Update Case Information

Not everything you might want to change lives in a custom field. Case status and milestone dates are part of the case itself, and `Service.UpdateCaseInfo` is how a script reaches them.

## The scenario

A customer rating on a case drops to fifty or below. The case should close. If the rating is above fifty but below one hundred, the case should reopen.

| Setting       | Value                  |
| ------------- | ---------------------- |
| Trigger field | `6364` Customer rating |

## The script

```javascript
[Changed.CustomField(6364).Changed]

function on_save() {
    if (Changed.CustomField("6364").NewValueAsNumber <= 50) {
        Service.UpdateCaseInfo("status", "Closed");
        Service.AddMessage("The case has been closed.", "notify-success");
        return true;
    }

    if (Changed.CustomField("6364").NewValueAsNumber < 100) {
        Service.UpdateCaseInfo("status", "Open");
        Service.AddMessage("The case has been reopened.", "notify-success");
        return true;
    }

    Service.AddMessage("The rating is out of range, so the case status was not changed.", "notify-error");
    return false;
}
```

## Status values that work

`UpdateCaseInfo("status", value)` recognises three values in any capitalisation:

| Value     | Effect                                        |
| --------- | --------------------------------------------- |
| `Open`    | Reopens the case and clears its close date    |
| `Pending` | Sets the case to pending                      |
| `Closed`  | Closes the case and stamps today's close date |

Any other word is stored as free text and displayed as the status, but the case is not treated as closed in reports or filters. `"close"` and `"closed"` are not the same thing.

## Milestone dates

Milestone dates use a field name of the form `milestone.<name or id>`:

```javascript
Service.UpdateCaseInfo("milestone.FileReview", "2026-04-15");
```

The value must be a date, or empty to clear it. A milestone that does not exist on the case produces an error message rather than a silent failure.

See the [Script API Reference](/developer-documentation/case-scripting/on-save-scripts/script-api-reference.md) for the full behaviour of `UpdateCaseInfo`.

## Initial case information

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

The case information panel before the custom field value is changed.

## Notification message

<figure><img src="/files/XOYECgAaokzmPULs35no" alt="" width="236"><figcaption></figcaption></figure>

Once the custom field has been saved, the script's notification confirms the change.

## Updated case information

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

After the case is refreshed, the status reflects what the script wrote.


---

# 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/on-save-scripts/examples/update-case-information.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.
