ccrz.ccApiConfig.setBulk

Loan storefront configuration data by passing in serialized JSON data or loading JSON-formatted data from a static resource. This method only adds new configuration data, and doesn't update existing configurations.

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

This method doesn't support service layer extensions or overrides.

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.ccApiConfig.CONFIG_JSON
String of the serialized JSON configuration data to load.
ccrz.ccApiConfig.FILE_NAME_LIST
List<String> of filenames within the static resource that contain the JSON-formatted configuration data to load.
ccrz.ccApiConfig.STATIC_RESOURCE
String that specifies the name of a static resource that contains the JSON data to load. Don't include the .resource extension. For example, if your static resource name is configDataToLoad.resource, specify only configDataToLoad for this key value.
ccrz.ccApiConfig.STATIC_RESOURCE => 'configDataToLoad'

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

Example for a Static Resource

Load configuration data from a static resource named configDataToLoad.resource, which includes two files with JSON-formatted configuration data, configDataFile.json and configDataFile2.json.

Map<String, Object> configDataFromStaticResource = new Map<String, Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccAPI.CURRENT_VERSION,
    ccrz.ccApiConfig.STATIC_RESOURCE => 'configDataToLoad',
    ccrz.ccApiConfig.FILE_NAME_LIST => new List<String>{'configDataFile.json', 'configDataFile2.json'};
};

try {  
    ccrz.ccApiConfig.setBulk(configDataFromStaticResource);
} catch (Exception e) {
    // Error handling...
}

In each JSON file in the static resource, use the following format.

{
    "ConfigurationMetas":[
        {
            "Name":"piname",
            "APIName":"piname",
            "Description":"Header Include End Page Include",
            "ExternallySafe":false,
            "Configurations":[
                {
                    "TextValue":"cc_EmptyPage",
                    "Storefront":"Global",
                    "PageName":"all",
                    "Name":"a0M360000015nqH"
                }
            ]
        },
        {
            "Name":"enabled",
            "APIName":"enabled",
            "Description":"Header Include End Enablement flag",
            "ExternallySafe":false,
            "Configurations":[
                {
                    "TextValue":"FALSE",
                    "Storefront":"Global",
                    "PageName":"all",
                    "Name":"a0M360000015nqT"
                }
            ]
        }
    ],
    "APIName":"hie",
    "Name":"Header Include End"
}

Example for Serialized JSON

Load configuration data from a serialized JSON string.

Enclose the JSON in a set of square brackets, [ ].

Note

Map<String, Object> configDataFromString = new Map<String, Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccAPI.CURRENT_VERSION,
    ccrz.ccApiConfig.CONFIG_JSON => '[
        {
            "ConfigurationMetas":[
                {
                    "Name":"piname",
                    "APIName":"piname",
                    "Description":"Header Include End Page Include",
                    "ExternallySafe":false,
                    "Configurations":[
                        {
                            "TextValue":"cc_EmptyPage",
                            "Storefront":"Global",
                            "PageName":"all",
                            "Name":"a0M360000015nqH"
                        }
                    ]
                },
                {
                    "Name":"enabled",
                    "APIName":"enabled",
                    "Description":"Header Include End Enablement flag",
                    "ExternallySafe":false,
                    "Configurations":[
                        {
                            "TextValue":"FALSE",
                            "Storefront":"Global",
                            "PageName":"all",
                            "Name":"a0M360000015nqT"
                        }
                    ]
                }
            ],
            "APIName":"hie",
            "Name":"Header Include End"
        }
    ]'
};

try {  
    ccrz.ccApiConfig.setBulk(configDataFromString);
} catch (Exception e) {
    // Error handling...
}