# Related data invalidation

{% hint style="success" %}
This is the official documentation of the `forestadmin/laravel-forestadmin` v2+ and `forestadmin/symfony-forestadmin` PHP agents.
{% endhint %}

Your actions may edit records that the user is currently viewing. This is usually not an issue, as after the successful execution of an action, Forest Admin will reload all data that is displayed on the current page.

This is always true, except for a single case: Related Data displayed in [custom-built Summary Views](https://docs.forestadmin.com/user-guide/getting-started/master-your-ui/build-a-summary-view). In this case, to avoid displaying stale data, you may want to tell the GUI which data has gone stale.

### Example

In the example below, the “Add new transaction” action is accessible from the summary view. This action creates a new transaction and automatically refreshes the “Emitted transactions” Related Data section to see the new transaction.

![](/files/zZ04iwKYhlmWMel7gtE9)

```php
use ForestAdmin\AgentPHP\DatasourceCustomizer\CollectionCustomizer;
use ForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\BaseAction;
use ForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\Context\ActionContextSingle;
use ForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\ResultBuilder;
use ForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Actions\Types\ActionScope;

$forestAgent->customizeCollection(
    'Company',
    function (CollectionCustomizer $builder) {
        $builder->addAction(
            'Add new transaction',
            new BaseAction(
                scope: ActionScope::SINGLE,
                execute: function(ActionContextSingle $context, ResultBuilder $resultBuilder) {
                    /* ... Create new transaction here ... */

                    // Tell the GUI to refresh the "emitted_transactions" related data section.
                    // (see left arrow of the screenshot above)
                    return $resultBuilder->success(
                        'New transaction emitted',
                        ['invalidated' => ['emitted_transactions']]
                    );
                }
            )
        );
    }
);
```


---

# Agent Instructions: 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:

```
GET https://docs.forestadmin.com/developer-guide-agents-php/agent-customization/actions/related-data-invalidation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
