> For the complete documentation index, see [llms.txt](https://docs.pentaho.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pentaho.com/pba-ctools/pentaho-cdf-api/cdf/addin.md).

# AddIn

## cdf. AddIn

Creates a new add-in. Add-ins come in two varieties: Static add-ins represent static data or behavior, while Scriptable add-ins represent dynamic, context-dependent behavior.

**AMD Module**

`require(["cdf/AddIn"], function(AddIn) { /* code goes here */ });`

## Constructor

| Name               | Description                                              |
| ------------------ | -------------------------------------------------------- |
| new AddIn(options) | Class that allows creating Static or Scriptable add-ins. |

## Methods

| Name                                                | Description                                                                      |
| --------------------------------------------------- | -------------------------------------------------------------------------------- |
| call(target, state, options) : `Object` \| `Object` | Executes the add-in `_implementation` function or returns the value of `_value`. |
| getLabel() : `string`                               | Returns the add-in label.                                                        |
| getName() : `string`                                | Returns the add-in name.                                                         |
| setDefaults(defaults)                               | Sets the default values of the configurable settings.                            |

## Constructor Details

| **new AddIn**(options)                                                         |               |                                                                                                                                                                                                                                                            |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| ------------------------------------------------------------------------------ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | ---- | ----------- | - | ----------- | ---------------------------------------------- | - | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---- | - | - |
| <p>The constructor of an add-in.</p><p>\*\*Source:\*\*AddIn.js, line 20</p><p> | Name          | Description                                                                                                                                                                                                                                                |   | ---- | ----------- |   | `TypeError` | If the `options` parameter is not an `object`. |   | `TypeError` | If `options.name` or `options.label` are not provided. Also, either `options.implementation` or `options.value` needs to be defined. | </p> |   |   |
| Name                                                                           | Default Value | Summary                                                                                                                                                                                                                                                    |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| options : `Object`                                                             |               | The options for the add-in. Needs a label, a name property, and either a value (for static add-ins) or an implementation member (for scriptable add-ins). If the add-in supports configuration, it should be provided via the `options.defaults` property. |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| Name                                                                           | Default Value | Summary                                                                                                                                                                                                                                                    |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| label : `string`                                                               |               | The human-readable label of the add-in.                                                                                                                                                                                                                    |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| name : `string`                                                                |               | The name of the add-in used as an internal identifier.                                                                                                                                                                                                     |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| implementation : `function`Optional                                            |               | The implementation function of the add-in.                                                                                                                                                                                                                 |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| value : `Object`Optional                                                       |               | The value of the add-in.                                                                                                                                                                                                                                   |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |
| defaults : `Object`Optional                                                    |               | The default values of the configurable settings.                                                                                                                                                                                                           |   |      |             |   |             |                                                |   |             |                                                                                                                                      |      |   |   |

| Name                                | Default Value | Summary                                                |
| ----------------------------------- | ------------- | ------------------------------------------------------ |
| label : `string`                    |               | The human-readable label of the add-in.                |
| name : `string`                     |               | The name of the add-in used as an internal identifier. |
| implementation : `function`Optional |               | The implementation function of the add-in.             |
| value : `Object`Optional            |               | The value of the add-in.                               |
| defaults : `Object`Optional         |               | The default values of the configurable settings.       |

| Name                                | Default Value | Summary                                                                                                                                                                                                                                                    |
| ----------------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options : `Object`                  |               | The options for the add-in. Needs a label, a name property, and either a value (for static add-ins) or an implementation member (for scriptable add-ins). If the add-in supports configuration, it should be provided via the `options.defaults` property. |
| Name                                | Default Value | Summary                                                                                                                                                                                                                                                    |
| label : `string`                    |               | The human-readable label of the add-in.                                                                                                                                                                                                                    |
| name : `string`                     |               | The name of the add-in used as an internal identifier.                                                                                                                                                                                                     |
| implementation : `function`Optional |               | The implementation function of the add-in.                                                                                                                                                                                                                 |
| value : `Object`Optional            |               | The value of the add-in.                                                                                                                                                                                                                                   |
| defaults : `Object`Optional         |               | The default values of the configurable settings.                                                                                                                                                                                                           |

| Name                                | Default Value | Summary                                                |
| ----------------------------------- | ------------- | ------------------------------------------------------ |
| label : `string`                    |               | The human-readable label of the add-in.                |
| name : `string`                     |               | The name of the add-in used as an internal identifier. |
| implementation : `function`Optional |               | The implementation function of the add-in.             |
| value : `Object`Optional            |               | The value of the add-in.                               |
| defaults : `Object`Optional         |               | The default values of the configurable settings.       |

\## Methods Details

| **call**(target, state, options) : `Object` \| `Object`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                                              |                                                                      |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| <p>Call the add-in. If the add-in is static, all parameters are irrelevant, and this method will simply return the value of <code>\_value</code>.</p><p>In a dynamic add-in, the implementation will be passed to the target DOM Element (whatever element is relevant, e.g. the element that was clicked on or the table cell that is being processed), a state object with whatever context is relevant for the add-in to fulfill its purpose, and optionally any overriding options.</p><p>Components are allowed to pass <code>undefined</code> as the target if no elements make sense in context.</p><p>\*\*Source:\*\*AddIn.js, line 153</p> |                                                                              |                                                                      |
| Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Default Value                                                                | Summary                                                              |
| target : `jQuery`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                                                              | The relevant DOM element.                                            |
| state : `Object`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |                                                                              | A representation of the necessary context for the add-in to operate. |
| options : `Object`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                              | Configuration options for the add-in.                                |
| Name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | Description                                                                  |                                                                      |
| `Object`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | The value of `_value` if the `_implementation` function is undefined.        |                                                                      |
| `Object`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | The result of executing the `_implementation` function when it is available. |                                                                      |

| Name     | Description                                                                  |
| -------- | ---------------------------------------------------------------------------- |
| `Object` | The value of `_value` if the `_implementation` function is undefined.        |
| `Object` | The result of executing the `_implementation` function when it is available. |

| Name               | Default Value | Summary                                                              |
| ------------------ | ------------- | -------------------------------------------------------------------- |
| target : `jQuery`  |               | The relevant DOM element.                                            |
| state : `Object`   |               | A representation of the necessary context for the add-in to operate. |
| options : `Object` |               | Configuration options for the add-in.                                |

| **getLabel**() : `string`                                                |                   |
| ------------------------------------------------------------------------ | ----------------- |
| <p>Returns the add-in label.</p><p>\*\*Source:\*\*AddIn.js, line 114</p> |                   |
| Name                                                                     | Description       |
| `string`                                                                 | The add-in label. |

| Name     | Description       |
| -------- | ----------------- |
| `string` | The add-in label. |

| **getName**() : `string`                                                |                  |
| ----------------------------------------------------------------------- | ---------------- |
| <p>Returns the add-in name.</p><p>\*\*Source:\*\*AddIn.js, line 124</p> |                  |
| Name                                                                    | Description      |
| `string`                                                                | The add-in name. |

| Name     | Description      |
| -------- | ---------------- |
| `string` | The add-in name. |

| **setDefaults**(defaults)                                                                                                                                                                                                                                                                                |               |                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------- |
| <p>Sets the default values of the configurable settings. If <code>defaults</code> is a <code>function</code> it will override any previous default values. If it is an <code>object</code> its properties will be used to extend the current default values.</p><p>\*\*Source:\*\*AddIn.js, line 176</p> |               |                                                   |
| Name                                                                                                                                                                                                                                                                                                     | Default Value | Summary                                           |
| defaults : `Object`                                                                                                                                                                                                                                                                                      |               | The default values for the configurable settings. |

| Name                | Default Value | Summary                                           |
| ------------------- | ------------- | ------------------------------------------------- |
| defaults : `Object` |               | The default values for the configurable settings. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pentaho.com/pba-ctools/pentaho-cdf-api/cdf/addin.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
