> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# newDefForInsight()

- Package: [@gooddata/sdk-model](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/index.md)
- Kind: function
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-model/src/execution/executionDefinition/factory.ts

Prepares a new execution definition for the provided insight.

**Signature:**

```typescript
export declare function newDefForInsight(workspace: string, insight: IInsightDefinition, filters?: INullableFilter[]): IExecutionDefinition;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| workspace | string | workspace to execute against, must not be empty |
| insight | [IInsightDefinition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iinsightdefinition/index.md) | insight to create execution for, must have buckets which must have some attributes or measures in them |
| filters | [INullableFilter](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.inullablefilter/index.md)[] | _(Optional)_ optional, may not be provided |

**Returns:**

[IExecutionDefinition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.iexecutiondefinition/index.md)

## Remarks

Buckets with attributes and measures WILL be used to obtain attributes and measures - the behavior WILL be same as in forBuckets() function. Filters, sort by and totals in the insight WILL be included in the prepared execution.

Additionally, an optional list of additional filters WILL be merged with the filters already defined in the insight.

- Attributes and measures from insight's buckets are distributed into definition attributes and measures  in natural order. - Insight filters are added into definition - Insight sorts are added into definition - Insight totals are added into definition

This function MUST be used to implement IExecutionFactory.forInsight();
