---
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, Presentation Components, widgets, tags, UI components]
nav: wcp_docs
parent_url: /wcp_docs/
title: script
layout: subsection
wd_wcptag: script
---

<a id="section_N10021_N1001E_N10001"></a>
A PMD property that specifies a multiline script enclosed by the `<% %>` notation.

In a `script` block, use the PMD Scripting syntax to declare functions that the PMD widgets can call. The functions you declare in the script block are available to all widgets within the same PMD.

<b>Note:</b> Unless you have an explicit `return` statement, the last line of a PMD script is the return value. If you want to log the return value of the script on the console, ensure that the last line returns the value after the `console` method call. Example:

```
"value": "<% var result = getStaticText();
             console.info(result);
             result;
          %>"
```

Use `script` on view and edit pages.

## <a id="section_mobileSupport"></a>Mobile Support

Android, iOS

## <a id="section_vq3_k3y_h2b"></a>Example

This `script` property declares a function that performs a simple validation and writes to the console:

```
"script": "<%
  var validateFields = function() {
    if (empty field1.value || empty field2.value || field1.value[0] == field2.value[0]) {
        field2.clearWarning();
    } else {
        console.info('field1 value: ', field1.value[0], ' - field2 value: ' , field2.value[0]);
        field2.setWarning('You didn\\'t select matching options. Try again!');
    }
  };
%>"
```

These sample widgets specify the `onChange` attribute to call the appropriate function when the event triggers:

```
{
  "type": "dropdown",
  "label": "List 1",
  "id": "field1",
  "instanceList": [
    {
      "id": "Foo",
      "descriptor": "Foo"
    },
    {
      "id": "Bar",
      "descriptor": "Bar"
    }
  ]
},
{
  "type": "dropdown",
  "label": "List 2",
  "id": "field2",
  "instanceList": [
    {
      "id": "Foo",
      "descriptor": "Foo"
    },
    {
      "id": "Bar",
      "descriptor": "Bar"
    }
  ],
  "onChange": "<% validateFields(); %>"
}
```

