---
title: "sfdcQuery"
canonical: "https://support.appfire.com/space/PSJ/15482730/sfdcQuery"
format: markdown
---
> Macro (aura-html)


Use the Salesforce Object Query Language (SOQL) to search your Salesforce data for specific information. 

## Description

> Macro (excerpt)
> 
> Returns all the results in a single response as a json string, or if needed, returns part of the results and an identifier used to retrieve the remaining results.

  
Is the equivalent of a Select SQL statement or the analog of the Jira JQL. This search enables you to get the list of information about Salesforce objects in a json format (not the value or object directly) which you can use to fill out fields in Jira using a script.

SOQL supports **get **functionality with attachments and statuses.

# Syntax

**<span style="color: #3366ff">sfdcQuery(sfdcConnection, soqlQuery, [sfdcAPIVersion])</span>**

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| sfdcConnection | [SFDCConnection](https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15482612) | Yes | Salesforce Connection - it is the object resulted from the call to the **connectToSalesforce** function. |
| sfdcQuery | string | Yes | SOQL query, see more information in the [Salesforce documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm). |
| sfdcAPIVersion | string | No | Salesforce API version to be called when creating the account, it should have the following form:  
"vXX.X" - eg: "v43.0", "v42.0".   
It is not required and if empty the latest available version will be used. |

## Return type

JSON string

## Example

The first part of the example will get the names of the accounts from Salesforce and the second part will get ID and names of the Salesforce opportunities.

```
SFDCConnection conn = connectToSalesforce("SFDC_test");
logPrint("WARN", "Connected to SF: " + conn.instance_url + " - " + conn.access_token);
 
string result = sfdcQuery(conn, "SELECT name from Account");
logPrint("WARN", "SOQL result: " + result);


string result2 = sfdcQuery(conn, "SELECT id, name from Opportunity");
logPrint("WARN", "SOQL result: " + result2); 
```

## See also

> Macro (contentbylabel)