# Get Started with Query Designer

## Create a Query

Navigate to your **Workspace > Apps** and click on the gear icon <img src="/files/-MBCo7T7BtG64Zwffv31" alt="" data-size="line"> to activate the configuration mode of your apps. Next, click on the gear icon <img src="/files/-MBCo7T7BtG64Zwffv31" alt="" data-size="line"> of the app you want to configure. In the **Data** section you click on **Queries** to access the Query Designer. Click **New Query**.

![Create a new query in the Query Designer](/files/-MA7PPGDeka10-ew1gla)

A query contains [*Common*](/building-an-application/data/query-data/query-designer-common.md) attribute&#x73;*,* [*Fields*](/building-an-application/data/query-data/query-designer-fields.md)*,* [*Conditions*](/building-an-application/data/query-data/query-designer-conditions.md)*,* and [*Default Values*](/building-an-application/data/query-data/query-designer-default-values.md). Use those properties to create data selections in order to provide information in your apps and reports.

## Common attributes

Every query needs some general information in the system. It is defined in the **Common** tab of the Query Designer.

1. Give your query a name and an optional description in the **Name** section of the designer. You can enter language-specific information for your query. In our example, we are creating a query to retrieve log entries.
2. Choose a **Source** to query data from and provide an optional **Query Context** in case you need to handle relations between multiple entities.
3. Select a value for **Run Credential** to define who will be able to see the result of the query. In comparison **Edit Credential** specifies who will be allowed to edit this query.
4. Optionally, you can specify whether the query is only used in other configurations and therefore **Invisible for users** and tick the option **Use as report** to limit access to the query.
5. In addition, you can use a **Pre-Script Configuration** to create a values in it's **script** which can be used for setting the condition of the query, before it has been executed.

![Specify the Common properties of a newly created query](/files/-MBDs1UGNXRPeV82uU21)

## Fields selection

To display relevant information in your query you have to specify at least one field from the selected Source on the Common tab. Change to the tab **Fields**.

1. On the right-hand side you see the **Main Query Class** with a list of available entities to choose fields from.
2. Expand an entity to access a list of available fields to choose from. You can either choose to select *All* fields or tick individual fields from the entity. When done click on **Add fields**.
3. You can specify more properties of each field, ie. position, title, sort order, and handling of undefined values, in the list of Fields.
4. Optionally, you can add so-called **Virtual Fields** to your Query. Virtual fields are defined based on a **Script** and offer you a wide range of built-in functions to work with your data sources.

![Add Fields to a query and position them](/files/-MBDs1UOpS3XDFmYCgRT)

{% hint style="info" %}
You need to have at least one field to validate the query. You can add any number of fields to your query definition.
{% endhint %}

## Validate and Save a Query

Finally, click on **Validate** to verify that your selection of criteria is accepted by the Query Designer. Click on **Save** to store your query and return back to the list of queries in your app.


---

# 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.tivity.one/building-an-application/data/query-data/get-started-with-query-designer.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.
