---
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, PMD Scripting, Scripts]
nav: wcp_docs
parent_url: /wcp_docs/
title: >- 
  Concept: Event Handling with PMD Scripting
layout: subsection
---

## <a id="section_1"></a>PMD Scripting Event Handlers

Use PMD Scripting with event handlers to perform data manipulations, calculations, and validations as users interact with edit pages. Example: Using an `onChange` event handler, you can invoke a deferred endpoint to validate the user selection, adjust the data format, perform calculations, and set the values of other widgets.

To use an event handler, specify the event name as a tag attribute whose value is the script. This sample dropdown uses an onChange event handler that populates a text widget:

```
{
  "type": "dropdown",
  "label": "Select a country:",
  "id": "countryList",
  "idKey": "ISO_3166_1_Alpha_3_Code",
  "displayKey": "name",
  "values": "<% countries.items %>",
  "onChange": "<% countryCode.value = !empty self.value ? self.value[0] : '-none-' %>"
},
{
  "type": "text",
  "enabled": false,
  "id": "countryCode",
  "label": "Country Code:"
}
```

Event handlers on an edit page can reference the self variable to refer to the widget that triggered the event. You can use the `self` variable to refer to the widget conveniently within the context of the event handler. The above example uses the `self` variable instead of repeatedly using the tag ID <i>countryList</i>.

<b>Note:</b> Ensure that the widget includes the id attribute. In general, Workday recommends that you include the id attribute in your widget and tag definitions, especially for debugging purposes and widget interactions.

Depending on when the events trigger, event handlers can reference the widgets on the page. In general, event handlers can access widget values when they've become available on the page.

## <a id="section_2"></a>Page Load Events

This diagram illustrates the order of PMD Scripting events when an edit or view page loads:

![](GUID-fcf411b7-23df-496e-90bb-876fa5ac67e2-enHYPHENus.png "Page load event sequence")

-   The <b>1..**</b> notation on the diagram indicates the one-to-many invocations on a page with multiple endpoints and widgets.

    If a page has multiple inbound endpoints, the page concurrently invokes inbound endpoints unless there's endpoint dependency. If an endpoint depends on another endpoint, the page invokes the endpoints in the specified order.

-   An event handler on a view page can't reference the widgets on the page. In general, tag attributes and values on a view page can't reference other widgets.
-   The `onLoad` and `onSend` events during page load can’t access the widgets because these events trigger before the PMD tag processing. Use these events for massaging and preparing the inbound data before starting tag processing.


## <a id="section_4"></a>Widget Events

This diagram illustrates the PMD Scripting events that can trigger from the widgets:

![](GUID-4da15282-ad6d-4e6b-ba49-1b8fbc9594a1-enHYPHENus.png "Widget event sequence")

-   The `onChange` and other widget events trigger during user interaction. These events can access all widgets on the page using the available widget methods. See the <i>PMD Scripting Methods</i> section in the [PMD tag documentation](/wcp_docs/dyg1528862158582.html) for the widget.
-   An onChange event handler on a widget can access a cellTemplate widget in a grid by referencing the cellTemplate id. Example: cellTemplateTagId.value.
-   onRowAdd, onRowRemove, and onRowSelect event handlers can access a cell in the grid row by referencing the column id. Example: row.childrenMap.columnId. For more details, see the Grid Event Handling section in [Concept: grid](/wcp_docs/tgx1652476064414.html).
-   The `onSearch` event on the `instanceList` can access the widgets within the current row in a `grid` or current panel in a `panelList`.
-   All widget event handlers can invoke a deferred endpoint, which can trigger the onSend event. In this case, an onSend event handler can access the widgets on the page.


## <a id="section_5"></a>Page Submit Events

This diagram illustrates the order of events when a user clicks the OK button on the edit page:

![](GUID-801fad74-9822-4b3e-afd7-e3fa661bae14-enHYPHENus.png "Submit event sequence")

-   The <b>1..**</b> notation on the diagram indicates the one-to-many invocations on an edit page with multiple endpoints. The page submits outbound endpoints in their order of placement in the PMD code.
-   The `onSubmit`, `onSend`, and `onMultiPartSend` event handlers can access the widgets on the page. Note that although the event handlers can set the widget values, the page won’t display the new values after the user clicks OK to submit the page.


For more details about the PMD Scripting events, see [Reference: PMD Scripting Events](/wcp_docs/tgy1581495452394.html).

