# Queries

Salesforce queries in WireBootstrap use the `query` resource of the REST API to execute *SOQL* in Salesforce.  For details on this resource, visit [Execute a SOQL Query](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm).

## Creating Queries

To create a query against Salesforce in WireBootstrap, use the [standard table query interface in WireBootstrap](https://docs.wirebootstrap.com/wirebootstrap/creating-queries/select-queries). &#x20;

For example, to request a list of account records, use the `Account` entity.

```javascript
const query = wire.data.select().from("Account");
```

To filter the accounts returned, use the `where` method with a filter expression method.

```javascript
const query = wire.data.select().from("Account")
    .where().eq("Active__c", "Yes");
```

The `where` method also takes an optional string parameter to create custom filters.

```javascript
const query = wire.data.select().from("Account")
    .where("Name LIKE 'United*'");
```

## Execute Queries

After creating a query, execute the query in Salesforce using the `execAsync` method on the [data source](/salesforce/data-connector.md#data-source).

```javascript
const source = new wire.data.DataSource("sf", {
    ...
});

const tblAccounts = await source.execAsync(query);
```

Query results are returned in a [WireBootstrap DataTable](https://docs.wirebootstrap.com/wirebootstrap/working-with-datatables/datatables) object. &#x20;

```javascript
...

const tblAccounts = await.source.execAsync(query);

// grab an array of the first 10 account objects ordered by account name
const rows = tblAccounts.select().top(10).orderBy("Name").rows();

```

## Results

The datatable returned from the query contains the list of records requested from Salesforce.  However, the response returned from Salesforce contains much more data than can be represented in a WireBootstrap datatable. &#x20;

The [service provider](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#service-providers) for the WireBootstrap for Salesforce Data Connector has an extension method called `results` which will return the raw results from the last Salesforce query.

```javascript
...
const tblAccounts = await.source.execAsync(query);

const results = source.serviceProvider().results();
```

For more on service provider extensions methods, visit [Provider Extensions](https://docs.wirebootstrap.com/wirebootstrap/connecting-to-data/data-connectors#provider-extensions).


---

# 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.wirebootstrap.com/salesforce/queries.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.
