# AdaptableCustomExpressionFunction

Canonical page: https://www.adaptabletools.com/docs/reference/adaptablecustomexpressionfunction

A 3rd-party custom expression function: one **flat** object combining the
aql evaluation properties (`handler`, `returnType`, `operands`, docs, …)
with the Adaptable-specific enhancement properties (`icon`, `label`,
`isAvailable`, `rhs`, …).

The handler is typed against the public 
so evaluator internals are not part of the authoring contract.

Registered via `expressionOptions.customStandardFunctions` (boolean
predicates are custom standard functions with `returnType: 'boolean'`).

`returnType` is mandatory so AdapTable can distinguish predicates from
value-producing functions — prefer  /
`EXPRESSION_RETURN_TYPES`. `string & {}` keeps literal autocomplete while
remaining assignable when TypeScript widens `'boolean'` to `string` (common
for object literals in a `Record | callback` union).

Boolean predicates with `operands` of arity 1 or 2 appear in Query Builder
/ ColumnFilter (optional 
for the operator picker). Arity 0 / 3+ or non-boolean stay Expression-Editor-only.

`isAvailable` is narrowed to 
(not Layout / Cell Summary — those are aggregation-only).

```ts title="TypeScript"
export type AdaptableCustomExpressionFunction = Omit<AqlExpressionFunction<AdaptableExpressionContext> & AdaptableExpressionFunctionEnhancement, 'isAvailable' | 'returnType'> & {
    returnType: ExpressionReturnType | (string & {});
    isAvailable?: AdaptableStandardExpressionModule[] | ((context: ExpressionFunctionAvailabilityContext) => boolean);
};
```

###### References

[`AdaptableStandardExpressionModule`](https://www.adaptabletools.com/docs/reference/adaptablestandardexpressionmodule.md) | [`ExpressionFunctionAvailabilityContext`](https://www.adaptabletools.com/docs/reference/expressionfunctionavailabilitycontext.md)
