ccrz.ccApiTerms.fetch

Executes a SOQL query of terms records, and returns a list of records that match you query.

Compatibility

This reference applies to:

Release Managed Package Version API Version
B2B Commerce for Visualforce Winter ’21 4.13 12
B2B Commerce for Visualforce Spring ’20 4.12 11
B2B Commerce for Visualforce Summer ’19 4.11 10
B2B Commerce for Visualforce Spring ’19 4.10 9
B2B Commerce for Visualforce Summer ’18 4.9 8

You can still call older versions of the API for this method, which can accept different input keys or return different output keys. Any differences in behavior for older versions aren't documented in this topic.

Note

Signature

global static Map<String, Object> fetch(Map<String, Object>)

Service Layer Classes

Data Service Provider
ccrz.ccServiceTerms

Inputs (Required)

Map<String, Object> that must include the following required keys:

ccrz.ccApi.API_VERSION
The version of the B2B Commerce for Visualforce API to reference for the method call. We recommend that you use the ccrz.ccApi.CURRENT_VERSION constant whenever possible, and only reference a specific version for compatibility if necessary.

If this key isn't specified, the method returns a ccrz.ccApi.NoApiVersionException.

Note

Inputs (Optional)

The input map can also include the following keys:

ccrz.ccApi.API_SIZING
Map<String, Object> that specifies options for how the method returns data.

Specific data size requests don't apply to this method. The same fields are always returned for each object, regardless of any specific data size request in your input map.

Note

ccrz.ccApiTerms.LOCALE
String that specifies one of your storefront's supported locales.

If the input data doesn't include this key, the method falls back to ccrz.cc_CallContext.userLocale.

Note

ccrz.ccApiTerms.STOREFRONT
String that specifies the name of a storefront for filtering the query.

If the input data doesn't include this key, the method falls back to ccrz.cc_CallContext.storefront.

Note

ccrz.ccApiTerms.TYPE
String that specifies a type of term for filtering the query, such as All, Billing, or Shipping.

Outputs

Map<String, Object> that can include the following keys:

ccrz.ccApi.API_VERSION
Integer that indicates which API version was used for the query.
ccrz.ccApi.SUCCESS
Boolean
Value Usage
true The call completed.
false The call encountered errors.

B2B Commerce for Visualforce doesn't always return an exception for any errors that can occur. When this value is false, consider rolling back the API transaction to a previous savepoint.

Tip

ccrz.ccApiTerms.TERMLIST
List<Map<String, Object>>, where each Map<String, Object> represents a ccrz__E_Term__c record.
  • Each term record in the return data includes the same set of fields, regardless of any specific ccrz.ccApi.SIZING input data size request.
  • The return data includes only one term record of each type of term.

Note

Example

Fetch term records where:

  • Type is Shipping
  • Storefront is DefaultStore
  • Locale is en_US

For each returned term, capture its title in a string variable.

Map<String, Object> termsFetchQuery = new Map<String, Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
    ccrz.ccApiTerms.STOREFRONT => 'DefaultStore',
    ccrz.ccApiTerms.TYPE => 'Shipping',
    ccrz.ccApiTerms.LOCALE => 'en_US'
};

try {
    Map<String, Object> termsResults = ccrz.ccApiTerms.fetch(termsFetchQuery);
    if (termsResults.get(ccrz.ccApiTerms.TERMLIST) != null) {
        List<Map<String, Object>> outputTermsList = (List<Map<String, Object>>) termsResults.get(ccrz.ccApiTerms.TERMLIST);
        for (Map<String, Object> term: outputTermsList) {
            String termTitle = (String)term.get('title');
        }
    }
} catch (Exception e) {
    // Error handling...
}