---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, monitor, troubleshoot]
nav: wcp_docs
parent_url: /wcp_docs/
title: >- 
  Reference: Debugging Tools and Techniques
layout: subsection
---

<a id="section_iz5_dlb_dqb"></a>
Use these tools and techniques to help you troubleshoot and fix errors in your custom app.

<b>Note:</b> Don't debug with sensitive data, and avoid active debugging in production environments.

## <a id="section_consoleLogging"></a>Console Logging with PMD Scripting

To send debugging messages to the app logs, use the PMD Scripting `console` methods.

This sample script uses the `console.info` method to display the filtered filename from an inbound endpoint:

```
var getImage = function(){
    var result = getAttachments.data.filter
                   (x => {(x.fileName).contains('jpeg' )});
    var fileID = result[0].id ?: '';
    console.info('fileName is: ' + (result[0].fileName ?: ''));
    return fileID;
}
```

Notes:

-   Ensure that the `console` method isn’t the last line of a script. The last line of a script must be the return value.
-   Remember to comment out or delete the `console` statements when you’re done with debugging.


To see the console messages in the app logs:

1.  From the <b>Console</b> section of the Developer Site menu, select <b>Analytics</b>.
2.  Select the <b>Logs</b> tab.
3.  Add a filter.

    -   `wd_app_id` - The `applicationId` in the AMD.
    -   `wd_category` - Specify `console`.

4.  You can save the filter. Note that saved filters are available to all users in your account.


For details about the `console` method, see [Reference: PMD Scripting Logging](/wcp_docs/baq1581495151995.html).

## <a id="section_isp_x1b_dqb"></a>Displaying JSON Data in a textArea Widget

To inspect JSON data, use the `json:asJSON` or `json:stringify` PMD function and display it on a `textArea` widget. This technique is helpful when you want to debug a page error or an erroneous page flow.

<b>Note:</b> You can use `json:stringify` instead of `json:asJSON`. If you're using a variable of type Map, List, or Set, the `{object}.toJson` function is more concise. Example: `myVariable.toJson()`

This sample `textArea` displays the contents of the `flowVariables`. Displaying the `flowVariables` helps to see the incoming variables from a page flow.

```
 {  
   "type": "textArea",
  "value": "<% json:asJSON(flowVariables) %>" 
}
```

To format the JSON data with indentations for easier inspection, copy the `textArea` value and paste it into a JSON formatter. You can use any online JSON formatting tool.

<b>Note:</b> Remember to remove the `textArea` widget when you’re done with debugging.

## <a id="section_t5j_35c_dqb"></a>Inspecting Outbound Data

To inspect the data that's submitted to an outbound endpoint, you can use any of these techniques:

-   On the outbound endpoint, use the `onSend` event handler to write the `self.data` to the console.

    This example uses the `console.debug` method in an `onSend` event handler to display the outbound JSON payload before sending it to the outbound endpoint:

    ```
    {
      "name": "requisition",
      "baseUrlType": "workday-procurement",
      "url": "requisitions",
      "authType": "sso",
      "httpMethod": "POST",
      "onSend": "<%
        self.data = {:};
        self.data.requester = {:};
        self.data.requester.id = instanceListWorker.getValue()[0];
        self.data.requisitionLines = [];
        var requisitionLine = {:};
        requisitionLine.item = {:};
        requisitionLine.item.id = site.appProperties.purchaseItem;
        requisitionLine.quantity = 1;
        requisitionLine.memo = string:join([name.getValue(), title.getValue()], '|');
        self.data.requisitionLines.add(requisitionLine);
        console.debug('Debug outbound data', json:asJSON(self.data));
        self.data;
       %>"
    }
    ```

    <b>Note:</b> Ensure that the `console` method isn’t the last line of a script. The last line of a script must be the return value. In an `onSend` event handler, the last line must contain the data sent to the outbound endpoint.

-   Send the outbound endpoint to a flow variable, and display the flow variable on the next page.

    1.  In the `outboundEndpoints[]` of the edit page, add a flow variable that specifies the name of the outbound endpoint you want to debug.

        In this example, we want to inspect the outbound data sent to the `charity` outbound endpoint by adding the `debugCharityEndpoint` flow variable.

        ```
        {
          "name": "charity",
          "baseUrlType": "app",
          "url": "charities",
          "httpMethod": "POST",
          "authType": "sso",
          "values": [
            {
              "outboundPath": "createdBy.id",
              "value": "<% worker.id %>"
            },
            {
              "outboundPath": "image.id",
              "value": "<% (!empty(charityImage.id)) ? charityImage.id : null %>"
            }
          ]
        },
        {
          "type": "outboundVariable",
          "name": "requisitionVars",
          "variableScope": "flow",
          "values": [
            {
              "outboundPath": "debugCharityEndpoint",
              "value": "<% charity %>"
            }
          ]
        }
        ```

    2.  To display the flow variable, add a `textArea` tag at the top of the next page in the flow.

        ```
        {
          "type": "textArea",
          "id": "debugText",
          "label": "Debug the charity outbound data",
          "value": "<% json:asJSON(flowVariables.debugCharityEndpoint)%>"
        }
        ```

    3.  You can copy and paste the displayed JSON output into a JSON formatter.

-   Send the outbound data to a mock outbound endpoint. You can use a third-party tool that provides a test server for HTTP clients and enables you to view HTTP requests. Take extreme caution when debugging with third-party tools to avoid sending sensitive data.


## <a id="section_bhk_cbb_dqb"></a>Analytics Dashboard

To help with debugging performance and page errors, you can use the <b>Analytics</b> dashboard on the Extend Developer Site.

<b>Debugging poor performance</b>

To monitor the performance or troubleshoot performance bottlenecks in your app, select the <b>Performance</b> tab in the <b>Analytics</b> dashboard. You can view performance graphs that display the page load and response times.

You can filter the performance graphs by date and time range. You can also filter using these fields:

-   `wd_app_id` - The `applicationId` in the AMD.
-   `wd_page_id` - The `id` of the PMD.


<b>Debugging page errors</b>

If Presentation Components encounter an error in a PMD, they display a page error with a red banner and an error message. To help determine the cause of the error, view the app log entries on the <b>Logs</b> tab in the <b>Analytics</b> dashboard. You can filter the log entries on these fields:

-   `wd_app_id` - The `applicationId` in the AMD.
-   `wd_page_id` - The `id` of the PMD.
-   `wd_common_request_id` - The request ID in a page error window.
-   `wd_category` - Specify `pageError` for general page errors, or `pageError.script` for PMD Scripting errors.
-   `wd_env` - The tenant environment (WCPDEV, IMPL, SANDBOX, or PROD).


The <b>Performance</b> tab in the <b>Analytics</b> dashboard can also provide related insight into page errors. You can view graphs that display page errors and API response errors within a date and time range.

You can save your log filters. Note that saved filters are available to all users in your account. For a list of all log fields, see [Reference: Application Logs](/wcp_docs/hlt1558652308211.html).

## <a id="section_avs_3bb_dqb"></a>WQL Performance Logs

To troubleshoot performance issues in your WQL queries, use the <b>WQL Log Settings</b> on the <b>Edit Report Performance Log Settings</b> task to create WQL performance logs. Unlike the <b>Analytics</b> dashboards, these logs reside on your Workday tenant.

For details about creating and viewing WQL performance logs, see [Create and View WQL Performance Logs](/wcp_docs/bqc1550166734209.html) and [Reference: WQL Performance Log Fields](/wcp_docs/chr1550171576287.html).

### Related Information

[Concept: Analytics Dashboard](/wcp_docs/rfv1559328926672.html)

[Concept: PMD Best Practices](/wcp_docs/asx1597867253394.html)

