a!sfcDescribeSObjects() Function

Provides introspection into the metadata of the given Salesforce objects. This function is most useful during development when determining the available object fields and their types.

Syntax

a!sfcDescribeSObjects( scsExternalSystemKey, usePerUserCredentials, endpoint)

Common Parameters:

scsExternalSystemKey: (Text) The key from the Third Party Credentials admin console page that corresponds to the set of credentials that should be used to authenticate.

usePerUserCredentials: (Boolean) If true the credentials set in the Third-Party Credentials settings page by the current user running the expression will be used. If false the site-wide credential values will be used.

endpoint: (Text) The Salesforce endpoint URL to use for authentication. Possible values are "https://login.salesforce.com/services/Soap/u/27.0", which is used for production and development environments, and "https://test.salesforce.com/services/Soap/u/27.0", which is used for the Salesforce "sandbox" test environment. Update the 27.0 portion of the endpoint URL to match the version of the API that you are accessing. As a best practice, create a constant for this value.

Specific Parameters:

sObjectNames: (Text Array) The names of the Salesforce objects whose metadata will be returned

Returns

The function returns the standard connector result dictionary described in the main Connectors page.

If successful, the returned result field will contain list of dictionaries that each have two fields:

  • boName: The name of the business object being described
  • attributes: The attributes (fields) of the sObject, given as a dictionary containing a field for the name and another for that attribute's type as reported by Salesforce.

Note: This function returns a list in the result field. Indexing into the list is necessary in order to retrieve the details for a given sObject. See example.

Notes

If called multiple times in the same expression with the same parameters, only one query is made to Salesforce when the expression is evaluated and the result is reused for each identical call. This caching only applies within a single expression evaluation. Return values are not cached in separate expressions, or in separate evaluations of the same expression.

Examples

Retrieve a Attributes of a Given sObject

Copy and paste the expression into the INTERFACE DEFINITION in EXPRESSION MODE, save it, then call the interface in a Tempo Report to test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
=load(
  local!pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 50), 
  local!describeResult: a!sfcDescribeSObjects(
    scsExternalSystemKey: cons!SALESFORCE_SCS_KEY,
    usePerUserCredentials: true,
    endpoint: cons!SALESFORCE_ENDPOINT,
    sObjectNames: {"Account"}
  ),
  with(
    local!sObjectDataSubset: if(
      local!describeResult.success, 
      toDataSubset(local!describeResult.result[1].attributes, local!pagingInfo),
      null
    ),
    {
        a!textField(
          label: "An error occurred",
          readOnly:true,
          value: local!describeResult.error.message,
          showWhen: isnull(local!sObjectDataSubset)
        ),
        a!gridField(
          totalCount: local!sObjectDataSubset.totalCount,
          label:"Account Attributes",
          columns:{
            a!gridTextColumn(
              label: "Name",
              field: "Name",
              data: local!sObjectDataSubset.data.name
            ),
            a!gridTextColumn(
              label: "Type",
              field: "Type",
              data: local!sObjectDataSubset.data.type
            )
          },
          value: local!pagingInfo,
          saveInto: local!pagingInfo,
          rowHeader: 1,
          showWhen: not(isnull(local!sObjectDataSubset))
        )
    }
  )
)
FEEDBACK