---
title: "RecommendationWidgetItem"
slug: "cloud-sdk-search-recommendationwidgetitem-1539382"
abstract: "The RecommendationWidgetItem class represents a widget item for a recommendation widget."
---
# RecommendationWidgetItem

|     |     |
| --- | --- |
| Type | Class |
| Extends | `ResultsWidgetItem` |
| Import path | `@sitecore-cloudsdk/search/server` |

A widget item for a recommendation widget.

## Constructor

```typescript
RecommendationWidgetItem(
  entity: string,
  widgetId: string,
  recommendationOptions?: RecommendationOptions,
  sources?: ArrayOfAtLeastOne<string>
)
```

### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `entity` | `string` | Required.<br><br>The entity associated with the widget. |
| `widgetId` | `string` | Required.<br><br>The unique identifier of the widget.<br><br>To find the widget ID[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N67248fcfc8b58] in Sitecore Search, click **Widgets**. Widget IDs are in the **RFK ID** column.<br><br>Example: `"rfkid_7"` |
| `recommendations` | [`RecommendationOptions`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/types/cloud-sdk-search-recommendationoptions.html "RecommendationOptions") | Optional.<br><br>Options to determine which recommendations are given by a recommendation widget. |
| `sources` | `string[]` | Optional.<br><br>A list of source[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N6762bd56030ee] IDs that identify the [sources](https://doc.sitecore.com/search/en/users/search-user-guide/en/identify-the-required-source-type.html) to include results from. Useful for filtering results by source, for example, when managing multiple sites.<br><br>To find source IDs in Sitecore Search, on the menu bar, click **Sources**.<br><br>If set, the response will contain results only from the specified sources.<br><br>If unset, the response will return results from all sources.<br><br>Example: `["1062132", "1081839"]`<br><br>Minimum length: 1. |

## Properties

| Name | Type | Description |
| --- | --- | --- |
| `_recommendation` | [`Recommendation`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/interfaces/cloud-sdk-search-recommendation.html "Recommendation") | Optional.<br><br>The recommendation object of a widget item. |

## Accessors

The following properties are available to get and set:

### get recipe { .notintoc }

```typescript
get recipe(): Recipe | undefined
```

Returns the `recipe` property of the `RecommendationWidgetItem` instance.

### set recipe { .notintoc }

```typescript
set recipe(recipe: Recipe)
```

Sets the `recipe` of the `RecommendationWidgetItem` instance.

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `recipe` | [`Recipe`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/types/cloud-sdk-search-recipe.html "Recipe") | A recipe for recommendations. A recipe is used to determine which recommendations are given by a recommendation widget. |

## Methods

### _validateRecipe

Validates that the recipe ID is a non-empty string, and that the recipe version is an integer greater than or equal to `1`.

#### Signature { .notintoc }

```typescript
private _validateRecipe(recipe?: Recipe): void
```

#### Parameters { .notintoc }

| Name | Type | Description |
| --- | --- | --- |
| `recipe` | [`Recipe`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-browser/types/cloud-sdk-search-recipe.html "Recipe") | A recipe for recommendations. A recipe is used to determine which recommendations are given by a recommendation widget. |

#### Return value { .notintoc }

Returns void.

#### Errors { .notintoc }

- [`IV-0023`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-server/classes/troubleshooting-the-cloud-sdk.html#UUID-e753bca7-34cd-82c3-cb33-6c1996ac600f_section-idm4566641646518433950839438956 "IV errors")
- [`IV-0024`](https://doc.sitecore.com/sdk/en/developers/005/cloud-sdk/cloud-sdk-reference/cloud-sdk-search/cloud-sdk-search-server/classes/troubleshooting-the-cloud-sdk.html#UUID-e753bca7-34cd-82c3-cb33-6c1996ac600f_section-idm4566641646518433950839438956 "IV errors")

### resetRecipe

Resets `recipe` to `undefined`.

#### Signature { .notintoc }

```typescript
resetRecipe(): void
```

#### Return value { .notintoc }

Returns void.

### resetRecommendations

Resets `recommendation` to an empty object.

#### Signature { .notintoc }

```typescript
resetRecommendations(): void
```

#### Return value { .notintoc }

Returns void.

### toDTO

Maps the `RecommendationWidgetItem` instance to its DTO (data transfer object) format.

#### Signature { .notintoc }

```typescript
toDTO(): WidgetItemRecommendationDTO
```

#### Return value { .notintoc }

Returns the `RecommendationWidgetItem` instance in a standardized DTO format.

[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N67248fcfc8b58]: A *widget ID*, also known as the RFK ID, is a unique identifier assigned to every widget in Sitecore Search. Cloud SDK developers use the widget ID when requesting widget data and when capturing *events* that occur in a specific widget.

[^UUID-101b62f6-b640-ed11-1057-29646ebb9fb7_N6762bd56030ee]: A connector that retrieves items from a specified website, document, or repository, and indexes them so they are searchable. A source can be, for example, a web crawler, an API crawler, or an API push.
