---
schema_version: "1"
id: 70733c7fbe6cadf48223ace84accef97422c0ac0be681ef1d55898a56ad65d13
title: Diagnostic Tool for Standard Cart APIs
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/diagnostic-tool-cart.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/diagnostic-tool-cart.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7bdb52366d5ba447f619bb8ef8213389aadd85e4054e5dd1c45c9f8af0efa174
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Diagnostic Tool for Standard Cart APIs

Users can invoke the diagnostic tool for Standard Cart APIs remotely. The `TelcoAdminConsoleController` supports following types of remote calls for diagnostic APIs.

- `getDiagnosticDetails`returns a list of string (name of diagnostics to be performed). No parameter is required.
- `executeDiagnostics` executes the diagnostic and returns the result of diagnostic in output. Requires name of the diagnostic as `diagnosticName` parameter.

Below is a sample code, which performs the diagnostic remotely and generates the output in apex debug log files.

```
vlocity_cmt.TelcoAdminConsoleController controller = new vlocity_cmt.TelcoAdminConsoleController();

// get list of all diagnostics
Map<String, Object> output = controller.invokeMethod('getDiagnosticDetails', new Map<String, String>());


List<Object> diagnosticNames = (List<Object>) output.get('result');

List<Map<String, Object>> results = new List<Map<String, Object>>();

// iterate over the diagnostic list and execute each one
for(Object diagnosticName: diagnosticNames) {

    Map<String, Object> diagOutput = controller.invokeMethod('executeDiagnostics', new Map<String, String>{'diagnosticName'=> (String) diagnosticName});

    Map<String, Object> result = (Map<String, Object>) diagOutput.get('result');

    if(result != null) {
        // if there's a validationMessage, collect the diagnostic result and print in the end
        if(result.get('validationMessage') != null) {
            results.add(result);
        }
    }
}

for(Map<String, Object> result: results) {
    System.debug('--------');
    System.debug('Validation Type: ' + result.get('validationType'));
    System.debug(result.get('validationMessage'));
    System.debug(result.get('howToFix'));
    System.debug('--------');
}
```

Sample Output:
![Diagnostic Output](https://developer.salesforce.com/docs/media/diagnostic-output.png "Diagnostic Output")

## Adding Pre/Post Hook on Standard Cart API Diagnostic Tool APIs

To add pre/post hook logic on the diagnostic APIs, create an interface record with name `StdCartDiagnosticHook` and create an interface implementation with a custom class as the implementation.

Sample Custom Class:

```
public with sharing class CustomDiagClass implements vlocity_cmt.VlocityOpenInterface {

    public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {

        if(methodName.equals('getDiagnosticDetails.PostInvoke')) {

            List<Object> diagnosticList = (List<Object>) output.get('result');

            // add the name of custom diagnostic to the list of diagnostics to be performed
            if(diagnosticList != null)
            {
                diagnosticList.add('customDataValidation');
            }
        }
        else if(methodName.equals('executeDiagnostic.PostInvoke') && 'customDataValidation'.equals(input.get('diagnosticName')))
        {

            Map<String, Object> result = new Map<String, Object>();
            result.put('validationType', 'customDataValidation');

            boolean error = true;

            // perform diagnostic here.

            if(error)
            {
                result.put('validationMessage', '<Add validation message here>');
                result.put('howToFix', '<Mention steps on how to fix the issue.>');
                result.put('records', '<Mention record name or ids for which issue happens>');
            }
            output.put('result', result);
        }

        return true;
    }
}
```

In the Vlocity CMT Administration UI, diagnostic details are displayed as follows.

Sample Output:

![Diagnostic Details](https://developer.salesforce.com/docs/media/diagnostic-details.png "Diagnostic Details")
