# Shared Actions

Shared actions in Astera allow sharing an item or an action at multiple places. The item that needs to be used repeatedly can be extracted into a *Shared Action*, which can then be used wherever needed. Moreover, any changes or updates that need to be made to an item can be made only in the *Shared Action*, and all occurrences of the *Shared Action* item will automatically accommodate all the changes.

### **How to Create and Use Shared Actions**

There are two methods to create and use shared actions in Astera.

1. Creating a new *Shared Action* in the project.
2. Creating and saving an item from a flow as a *Shared Action.*

Let’s see how both methods work through the following use cases.

### **Use Cases**

#### **Use Case 1: Database Connection as a Shared Action**

A database connection needs to be used over and over again in a project. Instead of creating a new connection every time, we can create a *Shared Action* for the database connection and use it wherever it is needed within the project.

**Creating a Database Connection as a Shared Action**

Right-click your project in the *Project Explorer* and select *Add New Item*.

![](/files/e7pq5KdDcolPAaeSNFFq)

An *Add New Item* window will open. Select a *SharedAction* item from the window. Rename your *SharedAction* item and click *Add*.

![](/files/NVippYMD11Q7hafEeXTq)

This will add a *Shared Action* to your project. A *Shared Action* file has a .*Sact* extension.

![](/files/3d0U7Q5HEBBoeOw8W38s)

Double-click the newly created *Shared Action* to open it in the designer. Drag and drop a *Database Connection* object from *Toolbox > Resources* onto the designer.

![](/files/ooB1t7VspeHWbdC2gHsX)

Double-click the *DbConnection* Object. A *DbConnection* properties window will open. Add database connection details and click *OK*.

![](/files/kakSFOl6jBBCjDkwsKev)

The database connection is now configured as a *Shared Action*. Press Ctrl + S or go to *File > Save* to save the *Shared Action*.

You can now use your *Shared Action* in any flow within the project.

**Using Database Connection Shared Action in a Dataflow**

Open a dataflow that uses a [*DatabaseSource*](/dataflows/sources/database-table-source.md) object within your project. Open the *DatabaseSource* properties window by double-clicking on it.

Select the *Use Shared Connection* option. The dropdown will show a list of all the database connections saved as a *Shared Action*.

![](/files/zdOS0QS0cTdjX2n2Gb58)

Similarly, you can use the *SharedAction* in all dataflows, workflows or subflows within the project. If something changes in your database connection, you will only have to update it in the *Shared Action* and all the flows using it will automatically accommodate all the changes.

{% hint style="info" %}
**Note:** The Database Connection shared action can be used with any other object that supports the usage of shared connections. Some examples of these objects include the [*SQL Statement Lookup*](/dataflows/transformations/sql-statement-lookup.md) and [*SQL Query Source*](/dataflows/sources/sql-query-source.md) objects in a dataflow and the [*Run SQL Script*](/workflows/run-sql-script.md) and [*Run SQL File*](/workflows/run-sql-file.md) objects in a workflow.
{% endhint %}

#### **Use Case 2: Transformation Object as Shared Action**

The following dataflow extracts data from a database table using a [*DatabaseSource*](/dataflows/sources/database-table-source.md) object and converts the unit price of an item from USD to PKR using an expression. It then writes the data to an [*Excel Destination*](/dataflows/destinations/excel-workbook-destination.md).

![](/files/QfkON76NLFYmjK4W5Kzd)

To reuse this [*Expression*](/dataflows/transformations/expression-transformation.md) in various flows within the project, we can extract the *Expression* into a *Shared Action* and use it wherever it is needed.

**Saving an Expression as a Shared Action**

Right-click the *Expression* object and select *Save as Shared Action* option.

![](/files/dAoTDYyXz9wzEb8bZSAb)

Select a destination where you want to save the *Shared Action* file and provide a file name. Click *Save*.

![](/files/xUgdbmv4CN5PA3EGe1aZ)

The *Shared Action* file has been saved. To add it to the project, right-click on your project in the *Project Explorer* and select *Add Existing Items*.

![](/files/jT6i1n3vXlVSNYokomcT)

Select the *Shared Action* file you created from the file explorer window that appears. Click *Open*.

![](/files/iQHm9UYPqH68OyPqpXDR)

This will add the *Shared Action* file to your project.

{% hint style="info" %}
**Note:** To use a *Shared Action*, the *Shared Action* file must be within the same project where it is needed.
{% endhint %}

**Using a Shared Action**

To use the [*Expression*](/dataflows/transformations/expression-transformation.md) saved as a Shared Action in a flow, drag and drop the *Shared Action* (.sact file) from the *Project Explorer* to the designer.

![](/files/KkxlwEEZmmpxmBnFGOq7)

Notice that the Shared Action object title is italicized.

We can now use this *Shared Action Expression* in any other workflow, dataflow or subflow within the same project by dragging and dropping it wherever it is needed.

![](/files/DYxP3dhgdFLtGsQlaNgK)

Now, if we want to make a change to the [*Expression*](/dataflows/transformations/expression-transformation.md) (let’s say the currency exchange rate changes), we will only have to update the *Expression* in the *Shared Action* and all the flows using it will automatically accommodate all the changes.

#### **Changing a Shared Action back to Local Object**

To change a *Shared Action* back to a local object, right-click the *Shared Action* object and select *Change Shared Action to Local* option.

![](/files/tA9EcuHnbeXlkBzLfSgU)

#### **Editing a Shared Action**

To edit a *Shared Action*, right-click the *Shared Action* object and select the *Edit Shared Action File* option. This will redirect you to the *Shared Action* file where you can make the desired changes.

![](/files/Dj4kcrBkpNrTqz0prB6h)

#### **Editing Shared Action File Path**

To edit the *Shared Action* file path, double-click the *Shared Action* object. You can select a new path by clicking on the File (📂) icon under the *Shared Action Location* section of *Shared Action Properties* window.

![](/files/gCcIVhjnZGFFyIJA6nJ7)

This concludes our discussion on how to create and use shared actions in an Astera project.


---

# 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://documentation.astera.com/miscellaneous/shared-actions.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.
