> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/salesforce/executequery.md).

# ExecuteQuery

Execute a query to Salesforce.

Task version: 3.0.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Salesforce/tree/main/Frends.Salesforce.ExecuteQuery>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name             | Description                                                                                                               |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Query : `String` | <p>Query which will be executed.</p><p><br>Default: <code>-</code><br>Example: <code>SELECT Name from Customer</code></p> |
| {% endtab %}     |                                                                                                                           |

{% tab title="Connection" %}

| Name                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AuthenticationMethod : `AuthenticationMethod` | <p>Authentication method used to get a Salesforce access token.</p><p>Possible values:</p><ul><li><code>AccessToken</code>: Authenticate with an access token.</li><li><code>OAuth2WithPassword</code>: Authenticate by providing required information to fetch OAuth2 access token.</li><li><code>OAuth2WithClientCredentials</code>: Authenticate using OAuth2 client credentials grant flow.</li></ul><p><br>Default: <code>OAuth2WithPassword</code><br>Example: <code>UsernamePasswordOAuth</code></p> |
| InstanceUrl : `String`                        | <p>Salesforce instance URL. Required when using the AccessToken authentication method.</p><p><br>Default: <code>-</code><br>Example: <code><https://mydomain.my.salesforce.com></code></p>                                                                                                                                                                                                                                                                                                                  |
| AuthUrl : `String`                            | <p>Url used to authenticate to Salesforce with the OAuth2 password flow.</p><p><br>Default: <code><https://login.salesforce.com></code><br>Example: <code><https://mydomain.my.salesforce.com></code></p>                                                                                                                                                                                                                                                                                                   |
| 🗝AccessToken : `String`                      | <p>Reusable Salesforce access token. Required when using the AccessToken authentication method.</p><p><br>Default: <code>-</code><br>Example: <code>00Dxx0000000001!AQ8AQExampleToken</code></p>                                                                                                                                                                                                                                                                                                            |
| ClientId : `String`                           | <p>OAuth connected app client ID.</p><p><br>Default: <code>-</code><br>Example: <code>3MVG9d8..ExampleClientId</code></p>                                                                                                                                                                                                                                                                                                                                                                                   |
| 🗝ClientSecret : `String`                     | <p>OAuth connected app client secret.</p><p><br>Default: <code>-</code><br>Example: <code>ExampleClientSecret</code></p>                                                                                                                                                                                                                                                                                                                                                                                    |
| Username : `String`                           | <p>Salesforce username.</p><p><br>Default: <code>-</code><br>Example: <code><integration.user@example.com></code></p>                                                                                                                                                                                                                                                                                                                                                                                       |
| 🗝Password : `String`                         | <p>Salesforce password.</p><p><br>Default: <code>-</code><br>Example: <code>ExamplePassword</code></p>                                                                                                                                                                                                                                                                                                                                                                                                      |
| 🗝SecurityToken : `String`                    | <p>Salesforce security token appended to the password for the username-password OAuth flow when required.</p><p><br>Default: <code>-</code><br>Example: <code>ExampleSecurityToken</code></p>                                                                                                                                                                                                                                                                                                               |
| ApiVersion : `String`                         | <p>The API version to use when making requests to Salesforce.</p><p>If left empty, the default value is v61.0.</p><p><br>Default: <code>v61.0</code><br>Example: <code>-</code></p>                                                                                                                                                                                                                                                                                                                         |
| ReturnAccessToken : `Boolean`                 | <p>Also return access token which is fetched during authentication?</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                 |
| {% endtab %}                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| {% endtabs %}                                 |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Task Result

| Name                            | Description                                                                                                                                       |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| Body : `Object`                 | <p>Body of the response.<br>Example: <code>{"id": "abcdefghijkl123456789", "success": true, "errors": \[]}</code></p>                             |
| RequestIsSuccessful : `Boolean` | <p>Was the request successful?<br>Example: <code>true</code></p>                                                                                  |
| ErrorException : `Exception`    | <p>Exception that was thrown by the server.<br>Example: <code>System.Net.Http.HttpRequestException</code></p>                                     |
| ErrorMessage : `String`         | <p>Error message from the server.<br>Example: <code>System.Net.Http.HttpRequestException: Request failed with status code Unauthorized</code></p> |
| Token : `String`                | <p>OAuth2 access token.<br>Example: <code>abcdefghjklmn123456789</code></p>                                                                       |

## Task Changelog

Changelog for Task Frends.Salesforce.ExecuteQuery.

### \[3.0.0] - 2026-04-01

#### Changed

* \[Breaking Change] Move parameters related to Connection to new Connection parameter.
* Remove the empty Options parameter.
* Improve validation of input parameters.

#### Added

* Added a new authentication method for authentication by OAuth2 with client credentials

### \[2.2.0] - 2025-12-12

#### Changed

* Change throwing exception logic

### \[2.1.0] - 2025-03-18

#### Changed

* Update packages: Newtonsoft.Json 13.0.1 -> 13.0.3 RestSharp 107.3.0 -> 112.1.0 System.ComponentModel.Annotations 4.7.0 -> 5.0.0 coverlet.collector 3.1.0 -> 6.0.4 dotenv.net 3.2.0 -> 3.2.1 Microsoft.NET.Test.Sdk 16.7.0 -> 17.13.0 MSTest.TestAdapter 2.1.2 -> 3.8.3 MSTest.TestFramework 2.1.2 -> 3.8.3 nunit 3.12.0 -> 4.3.2 NUnit3TestAdapter 3.17.0 -> 5.0.0

### \[2.0.0] - 2024-08-19

#### Added

* Salesforce API version number can now be specified in input.

### \[1.1.0] - 2024-08-28

#### Changed

* Documentation link now links to a correct page in Frends Tasks.

### \[1.0.1] - 2022-05-27

#### Changed

* Fix for issue with referencing result-object in other elements.

### \[1.0.0] - 2022-03-07

#### Added

* Initial implementation of Frends.Salesforce.ExecuteQuery.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/salesforce/executequery.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
